调用意图时是否可以添加自定义菜单?
我想知道即使应用程序调用显示联系人列表的意图,是否也可以保持应用程序的选项菜单可用?我希望我的设置选项在应用程序中随处可用。
I am wondering if it is possible to keep my application's option menu available even when the application calls an intent which brings up the contact list? I would like my settings option to be available everywhere within the application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需在每个活动中进行膨胀,就可以在每个活动上显示相同的菜单。如果您继承 Activity 并赋予它此功能,它会更加干净。
You can have the same menu show on every activity simply by inflating it in each activity. It will be even more clean if you subclass Activity and give it this functionality.
您的菜单仅在您的应用程序中可用,其他应用程序无法使用它。为了确保每个活动都有一个菜单,请在基本活动类中创建菜单,并使所有活动扩展它。
You menu will only be available in your app , other apps cant use it. To make sure every activity has a menu create the menu in a base Activity Class and make all your activities extent it.