I want to have a view with several choices when I click an element of my ListView. I was thinking of implementing an AlertDialog but as I need more than 3 options it is not possible...
I also thought of putting my ListView in a FrameLayout and have an view with a gone visibility that I would turn visible at the click and update the content but I don't know If it's a good idea.
I could do with some advice,
Thanks for any idea.
You can use ContextMenu, if dialog works fine for you. If you don't want the dialog then use PopupWindow.
You could use ContextMenu
This tutorial may help.
Edit based on the comment:
Hmmm.. Since you want more than 3 options and icons in the menu that's displayed when a item is clicked; you could set an onclicklistener for an item in the list and on clicking switch to an Activity that extends a BaseAdapter along with your own custom layout.
I personally don't recommend this as it could complicate things quite a bit. Context menu is quite straightforward and way to go.
You can create another activity, and give it the dialog theme:
<activity android:theme="#android:style/Theme.Dialog">
This causes it to look like an AlertDialog, but you have full control over what it looks like.
Note that when I used this previously it was rather slow, at least in the emulator though.
Related
in my Android application (for tablets), I have a two pane layout. On the left is a fragment containing a navigation menu of sorts, and on the right is a fragment loaded with buttons.
Pressing one of these buttons should result in a AlertDialog popping up. It does, however it pops up over the entire application, instead of just that one fragment. Everything else works perfectly.
I'd be eternally grateful if we could find a solution for this particular issue :)
Thank you!
This question should be what you need. To change the size of your dialog, see this.
Alternatively, you could change the layout of your fragment when the button is clicked, which might be better or look nicer.
I think you can override a dialog to solute this problem
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!
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'm working through the 'notepad' tutorial given in the developer's guide: http://developer.android.com/guide/tutorials/notepad/index.html
For some reason, even when i'm using their solution files, the context menu does not come up with i 'click and hold' on a list entry.
The class extends ListActivity, and calls "registerForContextMenu(getListView());"
but I never see the context menu fire.
Any idea what's wrong with it?
The way they lay out the rows in that tutorial means that you can only actually make a selection on text, not just the row it's on. Are you pressing on the row itself?
You can fix that by using fill_parent instead of wrap_content in the layout_width attributes of the LinearLayout and ListView in notes_list.xml, and in the TextView inside notes_row.xml
You need to click the menu to bring up the 'Add Item' option.
If you're using the emulator, the menu is the icon on the bottom left that looks like a 2X3 array.
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.