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
Post a Comment