java - Display week in menu -
i want able display number of week in action bar inside picture. first attempt display title in icon shows either title or icon not both @ same time. next tried create different pictures been used icon containing number of week. can't find way change icon.
anybody have idea can do?
this code menu
<item android:id="@+id/action_week" android:title="p" android:showasaction="always" android:icon="@drawable/vecka0"/> <item android:id="@+id/menu_overflow" android:icon="@drawable/menu_large" android:showasaction="always" android:title="@string/vmeny"> <menu> <item android:id="@+id/action_confirm" android:title="@string/confirm_text" android:showasaction="ifroom" /> <item android:id="@+id/action_switch_company" android:title="@string/vswitch_company" android:showasaction="never"/> <item android:id="@+id/action_logout" android:title="@string/logout_text" android:showasaction="ifroom"/> </menu> </item>
and here menu want
shows icon not text
for in item tag mention.
<item android:id="@+id/action_week" android:title="p" android:showasaction="always|withtext" //this show icon , text both @ atime android:icon="@drawable/vecka0"/>
changing icons dynamicaly
you need have reference menu @ time of creation of menu first.
private menu mmenu; @override public boolean oncreateoptionsmenu(menu menu){ // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main_activity, menu); // save menu reference mmenu = menu; return super.oncreateoptionsmenu(menu); } // example - call when need change icon private void setactionicon(boolean showwithbadge){ menuitem item = mmenu.finditem(r.id.item_id); if(mmenu != null){ if(showwithbadge){ item.seticon(r.drawable.ic_with_badge); } else { item.seticon(r.drawable.ic_without_badge); } } }
Comments
Post a Comment