Android:选项卡中嵌套活动的选项菜单
我有一个 TabActivity,其中包含一个 Activity。选择活动的选项卡时,如果按“菜单”按钮,则会在父 TabActivity 中调用 onPrepareOptionsMenu,但不会在所选选项卡的活动上调用。
除非我在选项卡内部单击,否则不会显示选项卡中活动的选项菜单,然后我会调用这两个选项卡(这就是我想要的)。当选择选项卡时,有什么方法可以“聚焦”选项卡中的活动吗?
I have a TabActivity which contains an Activity. When the tab for the activity is selected, if I press the Menu button, onPrepareOptionsMenu is called in the parent TabActivity, but not on the activity for the tab which was selected.
The options menu for the activity in the tab isn't shown unless I click inside the tab, then I get calls to both (which is what I want). Is there any way to 'focus' the activity in the tab when the tab is selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将此代码用于所有选项卡活动,无需为 TabHost(主要活动)提供选项菜单,
我希望它会对您有所帮助。
谢谢你,
甘纳帕蒂。
Just use this code for all tab activity without giving option menu for TabHost (Main Activity)
I hope it will help you.
Thank you,
Ganapathy.
我不确定我是否理解这个问题。
如果您想刷新当前选项卡(焦点所在的选项卡),并且菜单来自父级(选项卡),请尝试以下操作:
在您使用的菜单内:
您应该在活动中实现刷新功能。
希望这对您有帮助。
阿德里安.
I am not sure I understand the question.
IF you want to refresh the current TAB, the one that is in focus, and the menu is from the parent (Tabs), try this:
Inside the menu you use:
You should have a refresh function implemented in your activity.
Hope this helps you.
Adrian.