在 Android 中按需显示上下文菜单
考虑一个带有使用 registerForContextMenu
设置上下文菜单的 Android ListView
。当用户长按项目视图时,会显示 ListView
项目的上下文菜单。
此外,我想在用户点击(不是长按)项目时显示上下文菜单(如果满足某些条件)。可以这样做吗?如何?
Consider an Android ListView
with a context menu set up with registerForContextMenu
. The context menu of a ListView
item is shown when the user long taps over the item view.
Additionally, I would like to show the context menu when the user taps (not long taps) on the item (if certain conditions are met). Is it possible to do this? How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过浏览Android源代码设法解决了这个问题。这就是我所做的:
I managed to solve this by browsing the Android source code. Here's what I did:
是的,从您的点击事件中调用 PerformLongClick 方法,它应该执行此操作
Yes call performLongClick method from your click event and it should do it