简体   繁体   English

三星银河标签3中硬件菜单按钮未打开

[英]Hardware menu button not opening in Samsung galaxy tab 3

I have a samsung galaxy tab3 and I have the menu implemented in the usual manner - ie 我有一个三星星系tab3,并且按常规方式实现了菜单-即

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.game_menu, menu);
    return true;
}

and for menu selected 并选择菜单

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.new_game:
        newGame();
        return true;
    case R.id.help:
        showHelp();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

In my xml ive used android:showAsAction="never" for items that I want to see in overflow and android:showAsAction="ifRoom" for items I want to see upfront. 在我的xml ive中,使用android:showAsAction="never"表示我想在溢出中看到的项目,使用android:showAsAction="ifRoom"表示我想先看到的项目。 But in this tablet I see only the ones with ifRoom set and the others just disappear and the menu button does not show the overflow items. 但是在此平板电脑中,我只能看到那些设置了ifRoom的平板电脑,而其他平板电脑却消失了,并且菜单按钮没有显示溢出项目。 I've looked at all answers on SO and tried the popular ones like setting minimum and target sdk versions to less than 11 and so on. 我已经看过SO上的所有答案,并尝试了一些流行的答案,例如将minimum and target sdk versions to less than 11等。 But the menu just wont come up. 但是菜单不会出现。 It works fine in devices that dont have the capacitive menu touch and an overflow button is shown in the action bar. 它在没有电容式菜单触摸的设备中运行良好,并且在操作栏中显示了一个溢出按钮。

Well it ended up working when I programmatically called openOptionsMenu with onKeyDown 好吧,当我通过onKeyDown编程方式调用openOptionsMenu时,它就开始工作了

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

         if (keyCode == KeyEvent.KEYCODE_MENU) {
            openOptionsMenu();
        }
        return true;
    };

也许您有一个不支持ActionBar的主题(如全屏显示)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM