Reputation: 1430
I'm using an ActionBar that displays some MenuItems icon. What I need, is to be able to replace or Hide some MenuItems when the activity opens. My problem is that I can't find a way to get a MenuItem reference outside the onCreateOptionsMenu() method... Any idea on how to do that ?
Upvotes: 0
Views: 350
Reputation: 7519
You can use onPrepareOptionsMenu (Menu menu)
to show/hide menu items in the activity:
@Override
public boolean onPrepareOptionsMenu (Menu menu) {
menu.getItem(0).setVisible(false);
return super.onPrepareOptionsMenu(menu);
}
Upvotes: 1