How to call onCreateOptionsMenu from code

I want to call onCreateOptionsMenu from code, because if I use:

menu.setGroupEnabled(0, false); 

WITH

 public Menu menu; public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; menu.add(0,0,0,"Option"); return true; } 

This does not work if the user has never pressed the menu button. How can i do this?

thanks

PS: If this is bad practice let me know

+6
source share
1 answer

I believe you want invalidateOptionsMenu()

+9
source

Source: https://habr.com/ru/post/948648/


All Articles