views:

153

answers:

3

Hi everybody,

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.

A: 

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.

primalpop
Yeah I tested that too but I was annoyed by the "no icon" of this type of menu...
Sephy
+1  A: 

You can use ContextMenu, if dialog works fine for you. If you don't want the dialog then use PopupWindow.

Karan
Actually, popupwindow suits best the level of customization of what I intended. but contextmenu would have worked for a lower level. Thanks for help
Sephy
A: 

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.

Mayra
I'm trying the popupWindow and if i can't get what I want, I'll go for your idea.I'm also thinking of getting the source code of the option menu and see what I can do with it.thx
Sephy