Android Menu option not appearing in Android 4.4

前端 未结 2 1594
一个人的身影
一个人的身影 2021-01-28 23:18

I have a options menu in my application which I have tested to work on Android 4.0. The code is as shown below:

@Override
    public boolean onCreateOptionsMenu(         


        
2条回答
  •  情歌与酒
    2021-01-29 00:14

    Good practice is to call through to the super class:

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.layout.menu, menu);
        return super.onCreateOptionsMenu(menu);
    }
    

    The reason you're not seeing the menu is probably that the device has a hardware menu button and that must be pressed to show the options menu.

    Are you using the emulator? What is the setup for that?

提交回复
热议问题