android - item icon doesn't appear in actionbar -
my problem menu item icon . can't see icon in action bar . there 1 activity in app . in fact it's simple hello word , want add icon action bar
menu.xml:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity" > <!-- black icon --> <item android:id="@+id/action_create_order" android:title="create order" android:orderincategory="1" app:showasaction="ifroom" android:icon="@drawable/ic_add_black_36dp" > </item> <!-- white icon --> <item android:id="@+id/action_setting" android:title="settins" app:showasaction="never" android:orderincategory="100" > </item> </menu>
mainactivity.java:
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_main , menu); return super.oncreateoptionsmenu(menu); } }
why icon doesn't appear in action bar ?
try changing
app:showasaction="ifroom"
to
app:showasaction="always"
edit:
i suggest change activity appcompatactivity , use toolbar actionbar
Comments
Post a Comment