开发者

Add a view/activity on top of a ListView [Android]

开发者 https://www.devze.com 2023-01-01 18:21 出处:网络
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 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 开发者_Python百科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.

0

精彩评论

暂无评论...
验证码 换一张
取 消