从后面的代码显示上下文菜单
这可能是一个简单的问题,但我一直在寻找答案,但找不到答案。是否有任何代码可以通过代码在 Android 上显示上下文菜单,而不是按菜单按钮?例如,当我触摸屏幕时它会调用上下文菜单?
This might be a simple question, but I've been looking around and can't find the answer. Is there any code to show the context menu on Android from a code, instead of pressing the menu button? E.g. when I touch the screen then it'll call the context menu?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用。
您可以在您的视图上
You can use
on your view.
每当您想要打开
Activity
时,都可以调用openContextMenu()
。请注意,这是一种相当不寻常的 UI 模式,您的用户可能没有想到。Call
openContextMenu()
on yourActivity
whenever you want to open it. Note that this is a rather unusual UI pattern, one that your users may not expect.您可以使用以下任意一项:
setOnCreateContextMenuListener
showContextMenuForChild
you can use any of the following:
setOnCreateContextMenuListener
showContextMenuForChild