简体   繁体   中英

How to call onCreateOptionsMenu from code

I want to call onCreateOptionsMenu from the 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;
}

It doesn't work if the user never pressed menu button. How can I do that?

Thanks

PS: If this is a bad practice let me know

我相信你想要invalidateOptionsMenu()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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