How do I hide a menu item in the actionbar?

I have an action bar with a menuitem. How can I hide/show that menu item?

This is what I’m trying to do:

MenuItem item = (MenuItem) findViewById(R.id.addAction);
item.setVisible(false);
this.invalidateOptionsMenu();

26 Answers
26

Leave a Comment