Android 菜单项仅在焦点位于特定小部件时显示
在我的 Android 应用程序中,我有一个列表视图和列表视图上方的一些其他按钮。我需要实现通过创建菜单项将列表视图的所选项目添加到我的收藏夹列表的功能。
我可以创建一个菜单项来单击并添加功能。
但它应该只在焦点位于任何列表视图项目上时显示菜单项,而不是当焦点位于任何其他按钮或任何项目上时显示菜单项。仅当焦点位于任何列表视图项目上并按下菜单按钮时,菜单项才应显示。
有人可以帮助我吗?
In my android application I have a list view and some other buttons above the listview. I need to implement the functionality to add the selected item of the listview to my favourites list by creating a menu item.
I can create a menu item to click and add the functionality.
But it should only show the menu item if the focus is on any listview item and not when the focus is on any other button or anyItem. the menu item should only display when the focus is on any listview item and press the menu button.
Can Someone help me please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用上下文菜单而不是尝试修改主菜单?看起来行为可能更符合 UI 指南。
Have you considered using a context menu instead of trying to modify the main menu? It seems like behavior might be more in line with the UI guidelines.