toolbar - Android set menu action visibility -


i have activity , fragment android.support.v7.widget.toolbar

can show menu item "action" after creating menu in oncreateoptionsmenu() making visible or ?

(after clicking custom button example)

can show menu item "action" after creating menu in oncreateoptionsmenu() making visible or ?

yes overriding onprepareoptionsmenu method : prepare screen's standard options menu displayed. called right before menu shown, every time shown. can use method efficiently enable/disable items or otherwise dynamically modify contents. make action item visible or gone below(just sample code).

@override public boolean onprepareoptionsmenu(menu menu) {      menuitem menuitemvadd = menu.finditem(r.id.action_vadd);      if (isshowvisualadd1) {             menuitemvadd.setvisible(true);      } else {             menuitemvadd.setvisible(false);      }      return super.onprepareoptionsmenu(menu); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -