I have an activity which one of its components is a EditText. The goal of it is the following: when user clicks/taps on it, another activity is called to select some items (categories). I have implemented it using an activity that extends listactivity and using a custom adapter to paint custom rows for items.
All is ok, but I guess if using a EditText is the best option. The problem using this kind of control is that when user clicks/taps on it, the virtual keyboard appears and I do not want it to appear. If I use a TextView instead, virtual keyboard does not appear, but it is not clear for user that he have to click/tap on it to select a category (as the underscore line is not shown here as when using EditText).
So what android widget is the best to use in this scenario?
You can always use expandable list view there are many examples online that could help u to create it much more flexible than a spinner and it looks elegant and easy to use, it also show the user directly what is used for by just giving it a look and u can always customize it and play with its look and functionality.
Sounds like you are looking for a Spinner? That way you wouldn't have to load up a separate Activity to make the category selection. Otherwise, why not just use a Button? It's obviously clickable, that's for sure!
Related
I have implemented below tree structure options in navigation, whenever user selects any option, I want activity content to change. Now the main challenge here is Activity content could be too big and It can include many types of fields like links, images, normal text. My purpose here is whenever user selects any option, activity will show that option related information. Now for the first option, it can have multiple images to show, text and links, second option click may not have links but it can have images, information text. Its more like XML structure will change dynamically based on user choice.
Navigation view with activity
I am new in android and I want efficient method to implement such functionality.
Below are the methods which I can think of
For each option click show new activity : I can't implement this because I would have to implement this navigation option code in each activity which is too complicated for me (if anyone has any better idea to implement this approach then please let me know)
Change XML content of activity dynamically : Can I do something like for each content I will write XML pages/file and change it dynamically, I would like to know how to implement this method.
I want to be able to do what is on the picture, provided by this link, under the "Allow cutting through hierarchies" section. I thought that I could do that using a spinner, but from the android documentation I realized that a spinner can show one child at a time and lets the user pick among them. In my case, (and from the example I provided), you have some other text displayed, and then you can choose from some other options provided in sth that looks like a popup, list that contains the things that i want to choose from. I don't know how this is implemented, but it's used in the google music app for android 4.0. If someone has an idea, have implemented sth like this, please give me some advice.
It is not a spinner. Its just a view (in the Mail app a relative layout) See here
On click this View opens a popupmenu.
Therefore it is looking like a spinner but you can add you custom behaviour.
I need your help, cause I'm thinking about how to resolve this problem and don't know what's the best method:
What I have:
I have a standard ImageGallery. Below this, there is a Button.
What I want:
When I press this Button, there shall be opened a List of all the images, consisting of a small image on the left and a short description in one row, all the content should be brought by an array in an extra folder.
By clicking one row, the chosen image should appear in the Gallery and the list should be closed.
What I am thinking:
is, that I have to create a custom Dialog (Alert Dialog?Binder?), started by the Button. This Dialog must be filled with a custom ListView.
What I don't know:
What components of the framework do I need for this? I have found some things with Google, but at least I'm not sure what's the most efficient way.
I saw, that somebody had created an extra activity for the Dialog, using a DialogLayout.
Someone else tried it with a builder, another one with an AlertDialog.
Furthermore, I'm confused about the combining of the ListView, ArrayAdapter, Dialog, ViewBinder, getView, Objects and so on.
Someone has an idea how to resolve this on the easiest way?
You need to do something like this:
Define an activity extending ListActivity.You can refer this tutorial how to use listactivity.
Add this activity in your manifest file with theme attribute android:theme="#android:style/Theme.Dialog" in your activity tag which will make your activity look like a dialog.
You can start this activity on your button click.
If you want some result should be returned to your calling activity then use startActivityForResult().
I apologize if I'm just missing the obvious. I'm fairly new to Android development, and while I searched for this particular topic, I wasn't exactly sure what to look for (in terms of a "name").
In an application I'm writing, I have a section where the user can enter the names of players. However, this can range anywhere from 1 to whatever, no limit. However, I'm not sure what the best approach for this kind of feature is, or if there's a component that already does something like it.
Basically, the functionality I'm looking for is similar to what you can see in the Edit Contact screen of the phone book; for the phone numbers and email addresses, you can push a little plus button to add a new number/address, or hit the little minus button to remove a number/address.
I can think of several ways to potentially implement this, but in the end I think wrapping it in a custom component would be best (so that you could call "Get Players" and have it return a list of strings by going through each of the inputs and getting the values).
Am I just overthinking this? Is there a component that does that already? Is there some example code that demonstrates a good way to do this?
Thanks!
Could you just use ListView and add a menu with a "Add Players" option? You could customize the list view to have a little checkbox, for example, and then begin the game by pressing the menu ... or add new players dynamically by pressing another menu button.
After playing around with some ideas, I came across a solution that I think will suit what I'm doing. I created a custom component extending LinearLayout. As part of the creation of the component, it creates a row that says "Add new..." with a plus-sign button. Pressing the plus sign button then creates a new row containing an EditText and a minus-button which will remove the row.
I then created a method for this component called getTexts() which returns a List that has all the non-empty Text values from all the components. Testing it in a dummy app, it seemed to work fine.
I think I need to make tweaks to make it more robust (like the ability to add rows programatically, listeners to alert other components when a row is added/removed, and the ability to set the individual EditText values, for instance), but this functions as I imagined.
I am trying to put together a modal box with a scrollable list of checkable items and an OK and Cancel button at the bottom for the user to select filters from. It seems the simplest way to do things like this in Android is to reuse API components (widgets, layouts, etc) and the closest one I can find to this looks to be the ListPreference, which basically does exactly what I want (I can even work with storing the data in SharedPreferences).
The problem is that I'm not launching this modal box from a PreferenceActivity, but rather will be launching it from either of two activities: a ListActivity and a MapActivity. If a ListPreference would be possible here, that'd be really convenient, but otherwise any help getting me in the right direction would be great.
Thanks!
Nick
Try an AlertDialog, supplying it with your ListAdapter via AlertDialog.Builder.