Android Menu Icon Not show using Toolbar -


my code using toolbar
has try using how show icons in overflow menu in actionbar
not work

android:minsdkversion="14" android:targetsdkversion="22" 
toolbar = (toolbar) findviewbyid(r.id.toolbar); toolbar.setlogo(r.drawable.ic_launcher); setsupportactionbar(toolbar); 
for(int i=0; < navdrawerarray.length; i++) {     switch (i) {         case 0:             icon = r.drawable.ic_action_dock;             break;         case 1:             icon = r.drawable.ic_action_time;             break;         case 2:             icon = r.drawable.ic_action_share_nav;             break;         case 3:             icon = r.drawable.ic_action_important;             break;         case 4:             icon = r.drawable.ic_action_about;             break;         case 5:             icon = r.drawable.ic_minimize;             break;         case 6:             icon = r.drawable.ic_action_cancel;             break;         default:             break;     }     menu.add(menu.none, i, menu.none, navdrawerarray[i]).seticon(icon); } return super.oncreateoptionsmenu(menu); 

such how show icons in overflow menu in actionbar

i move parts "setoptionaliconsvisible" onmenuopened onprepareoptionsmenu

@override public boolean oncreateoptionsmenu(menu menu) {     menuinflater inflater = getmenuinflater();     inflater.inflate(r.menu.main, actionmenu.getmenu());      for(int i=0; < navdrawerarray.length; i++) {         switch (i) {             case 0:                 icon = r.drawable.ic_action_computer;                 break;             case 1:                 icon = r.drawable.ic_action_download;                 break;             case 2:                 icon = r.drawable.ic_action_share;                 break;             case 3:                 icon = r.drawable.ic_action_important;                 break;             case 4:                 icon = r.drawable.ic_action_cancel;                 break;             default:                 break;         }         menu.add(menu.none, i, menu.none, navdrawerarray[i])             .seticon(icon)             .setshowasaction(menuitem.show_as_action_collapse_action_view);      }     return super.oncreateoptionsmenu(menu); } 
@override public boolean onprepareoptionsmenu(menu menu) {     if(menu != null){         if(menu.getclass().getsimplename().equals("menubuilder")){             try{                 method m = menu.getclass().getdeclaredmethod(                     "setoptionaliconsvisible", boolean.type);                 m.setaccessible(true);                 m.invoke(menu, true);             }             catch(nosuchmethodexception e){}             catch(exception e){}         }     }     return super.onprepareoptionsmenu(menu); } 

now icon visible


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -