Question

Hello Android Developers,

I have seen a lot of question regarding the update of Options Menu. However, every answer says I have to call invalidateOptionsMenu().

My question is, is there any other way of updating the Options Menu without invoking the method invalidateOptionsMenu()?

Was it helpful?

Solution

@Override
    public boolean onPrepareOptionsMenu(Menu menu) {

        menu.clear(); // Clear the menu first

            /* Add the menu items */

        return super.onPrepareOptionsMenu(menu);
    }

This solved the problem on updating the OptionsMenu without invoking the invalidateOptionsMenu()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top