[英]Can anyone help me figure out why my OptionsMenu won't show up?
I am using tabs, with Activity groups in each. 我正在使用选项卡,每个选项卡中都有“活动”组。 I want to add an options menu to certain activities but it won't show on any.
我想为某些活动添加一个选项菜单,但不会显示在任何菜单上。 I have options menus working in other projects with the exact same code, so I can't figure out why they won't show up.
我在其他项目中使用具有完全相同代码的选项菜单,因此我不知道为什么它们不会显示。 This is the code I am using:
这是我正在使用的代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("Option 1");
menu.add("Option 2");
menu.add("Option 3");
return super.onCreateOptionsMenu(menu);
}
Is there anything wrong with this code or anywhere else I should be looking at that might be blocking this menu from showing when I hit the menu button? 这段代码有什么问题吗?或者我应该查看的其他任何地方,可能会在我按下菜单按钮时阻止此菜单显示?
The only thing that would be blocking the menu AFAIK would be if you are overriding onKeyDown. 唯一会阻塞菜单AFAIK的事情是,如果您要覆盖onKeyDown。 Make sure you aren't overriding that method and thus preventing the menu button from doing what it is supposed to.
确保您没有覆盖该方法,从而防止菜单按钮执行应做的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.