简体   繁体   English

谁能帮我弄清楚为什么我的OptionsMenu无法显示?

[英]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.

相关问题 为什么 Quantity Text 没有出现在模拟器上? 谁能帮我解决这个问题? - Why Quantity Text does't appear on the emulator? can anyone help me out with this? Android无法弄清楚为什么“参考”屏幕不显示首选项文本框 - Android can't figure out why perference screen won't show preference textbox 输入后我的按钮将无法激活,我不知道为什么 - My button won't activate after typing in, I can't figure out why 谁能帮我依赖注入? - Can anyone help me out in dependency Injection? 有人可以帮我缩放RelativeLayout吗? - Can anyone out there help me for Zoom RelativeLayout? 有人可以帮助我为何我的OnClickListener无法正常工作吗? Android的 - can someone help me with why my OnClickListener won't work? Android 任何人都可以帮助我为什么我得到 null 值即使代码中没有错误 - can anyone help me out why I am getting null value even there is no error in the code 无法弄清楚我的应用为什么要求root ...? - Can't figure out why my app is requesting root…? 无法弄清楚为什么我在 EditText 上收到此 NullPointerException - Can't figure out why I get this NullPointerException on my EditText 我的Android应用程序崩溃无法弄清楚为什么? - My Android application crash can't figure out why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM