Add the following code to the parent class
public boolean isOpen = flase;//defaults to False@overridepublic boolean oncreateoptionsmenu (Menu menu) {Getmenuinflater (). Inflate (R.menu.news_ds_menu, menu); return true;//shows}public void Isrightbtnhide () {IsOpen = true;} @Overridepublic boolean Onprepareoptionsmenu (Menu menu) {//Hides the menu here Menu.finditem (R.id.news_share_item). setvisible ( IsOpen); return Super.onprepareoptionsmenu (menu);}
When called in another activity, add the following code
Isrightbtnopen ();//Set its status to Trueinvalidateoptionsmenu ();//recall <pre name= "code" class= "Java" > Oncreateoptionsmenu, <span style= "font-family:arial, Helvetica, Sans-serif;" >onprepareoptionsmenu to show it out </span>
This will be OK,
1, native Mactivity.getwindow (). Invalidatepanelmenu (Window.feature_options_panel); 2, Actionbarsherlockinvalidateoptionsmenu ();
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Dynamic Settings Actionbar