简体   繁体   中英

When will the method “onPrepareOptionsMenu” be called?

I create a menu.xml , only one action item with the "always" inside it. now I want to use the this method to change the menu's visible ,remove old action item , add new action item , change the old action item's icon ... so how to implement this ? I don't want the onCreateOptionMenu to be called more than once as the activity has presented by Android system.

onPrepareOptionsMenu() will be called automatically after onCreateOptionsMenu().

And if you called invalidateOptionsMenu() on any action-item click event, then , it will be called again.

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