onCreateOptionsMenu is never called

后端 未结 11 1073
有刺的猬
有刺的猬 2020-12-13 03:13

I am having some trouble getting an options menu working in Android. I have built apps before, and they all worked fine, but now the menu just doesn\'t pop up.

The c

11条回答
  •  一生所求
    2020-12-13 03:57

    In the latest versions of Android when using the compat library for toolbar, is very common that this happens, in order to get the menu items to display in the toolbar you must do the following:

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    

提交回复
热议问题