在 ListView 之上添加视图/活动 [Android]
当我单击 ListView 的元素时,我希望有一个具有多个选择的视图。我正在考虑实现一个 AlertDialog,但由于我需要 3 个以上的选项,所以这是不可能的...... 我还考虑将我的 ListView 放入 FrameLayout 中,并拥有一个可见性消失的视图,我将在单击时将其变为可见并更新内容,但我不知道这是否是一个好主意。 我可以提供一些建议,
谢谢你的任何想法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果对话框适合您,您可以使用 ContextMenu。如果您不想要该对话框,请使用 PopupWindow。
You can use ContextMenu, if dialog works fine for you. If you don't want the dialog then use PopupWindow.
您可以使用 ContextMenu
本教程可能会有所帮助。
根据评论进行编辑:
嗯..因为您希望在单击某个项目时显示的菜单中有 3 个以上的选项和图标;您可以为列表中的某个项目设置一个 onclicklistener,然后单击切换到扩展 BaseAdapter 以及您自己的自定义布局的 Activity。
我个人不推荐这样做,因为它可能会使事情变得相当复杂。上下文菜单非常简单,而且非常好用。
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.
您可以创建另一个活动,并为其指定对话框主题:
这会使其看起来像一个 AlertDialog,但您可以完全控制它的外观。
请注意,当我以前使用它时,它相当慢,至少在模拟器中是这样。
You can create another activity, and give it the dialog theme:
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.