onCreateOptionsMenu is never called

后端 未结 11 1100
有刺的猬
有刺的猬 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 04:20

    I was having the same problem (menu not showing up, onCreateOptionsMenu not being called).

    If you are calling this within a fragment, you need to override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) not public boolean onCreateOptionsMenu(Menu menu). Fragments do not use the latter, so they will never even call it.

    Activity menu

    Fragment menu

提交回复
热议问题