Android action bar settings option not show on real device -


i have action bar have button , settings option . when run app on emmulator show both button , settings option. enter image description here

but on real device not show settings option enter image description here

please tell me how fix it?

this code of activity

 public class addnewdish extends actionbaractivity { @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_add_new_dish); getsupportactionbar().setdisplayhomeasupenabled(true);  @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.option, menu);         return super.oncreateoptionsmenu(menu);      } 

this menu xml code

    <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android">   <item android:id="@+id/action_settings"     android:title="@string/action_settings"     android:orderincategory="1"     android:showasaction="never" /> </menu> 

put below code on oncreate() of actionbaractivity:

try {   viewconfiguration config = viewconfiguration.get(this);   field menukeyfield = viewconfiguration.class.getdeclaredfield("shaspermanentmenukey");    if (menukeyfield != null) {     menukeyfield.setaccessible(true);     menukeyfield.setboolean(config, false);   } } catch (exception e) {  } 

done


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -