Reputation: 214
Can you please tell me how can I create an android menu item with icon. Im insert image from menu main.xml but not working
<item
android:id="@+id/menu_settings"
android:icon="@drawable/ic_launcher"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
<item
android:id="@+id/menu_cut"
android:icon="@drawable/ic_launcher"
android:orderInCategory="100"
android:showAsAction="never"
android:title="cut"/>
<item
android:id="@+id/menu_copy"
android:orderInCategory="100"
android:showAsAction="never"
android:title="copy"/>
<item
android:id="@+id/menu_past"
android:orderInCategory="100"
android:showAsAction="never"
android:title="past"/>
Upvotes: 3
Views: 10765
Reputation: 1062
You need to set showAsAction
as ifRoom|withText
<item
android:icon="@drawable/img"
android:title="title"
android:showAsAction="ifRoom|withText" />
Upvotes: 7
Reputation: 679
It's not supported in Android 3.0+ http://android-developers.blogspot.in/2012/01/say-goodbye-to-menu-button.html
Help this helps.
Upvotes: 0
Reputation: 1007584
Icons are used for toolbar buttons. You have android:showAsAction="never"
, forcing this item into the overflow. The overflow does not use icons.
Upvotes: 1
Reputation: 685
programmatically set the icon like this:
menu.add(0, MENU_QUIT, 0, "Quit").setIcon(R.drawable.menu_quit_icon);
or You can set it in your xml layout like this:
<item android:id="@+id/save_button"
android:icon="@android:drawable/ic_menu_save"
android:title="Save Image"/>
Upvotes: 0