-
2AFAIK, the native overflow menu does not support icons. – CommonsWare Mar 28 '16 at 11:41
-
2possible duplicate of [This](http://stackoverflow.com/questions/21861196/showing-custom-layout-on-overflow-drop-down-menu-item-android) – Aks4125 Mar 28 '16 at 11:42
-
Use Custom menu to show icon and text – sarika kate Mar 28 '16 at 11:47
-
@Aks4125 You r right. Its working. and sarika I tried custom, it wont work – bharat Mar 28 '16 at 12:14
3 Answers
If someone is still looking for an Answer, here's how I got it -
menu.xml
<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">
<item
android:id="@+id/a_More"
android:icon="@drawable/more"
android:showAsAction="always"
android:title="More" >
<menu>
<item
android:id="@+id/MENU_GOTO"
android:orderInCategory="100"
app:showAsAction="never"
android:showAsAction="never"
android:icon="@drawable/go_to"
android:title="Go To Page"/>
<item
android:id="@+id/MENU_OUTLINE"
android:orderInCategory="100"
app:showAsAction="never"
android:showAsAction="never"
android:icon="@drawable/outline"
android:title="Table of Contents"/>
<item
android:id="@+id/MENU_OPTIONS"
android:orderInCategory="100"
app:showAsAction="never"
android:showAsAction="never"
android:icon="@drawable/settings"
android:title="Settings"/>
<item
android:id="@+id/MENU_EXIT"
android:orderInCategory="100"
app:showAsAction="never"
android:showAsAction="never"
android:icon="@drawable/exit"
android:title="Exit"/>
</menu>
</item>
</menu>
And in Activity -
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu);
return super .onCreateOptionsMenu(menu);
}

- 4,020
- 2
- 18
- 49
http://www.androidhive.info/2013/11/android-working-with-action-bar/
Here the important xml attributes should be known are
android:icon – Defines the icon of the action item.
android:title – Title for the icon.
android:showAsAction – Defines the visibility of the action item. It accepts following values.
always: Forces to display the icon always irrespective of space available. This way is not suggested.
withText Displays a text along with the icon. Normally the text value defined by android:title will be displayed
You can use withText for android:showAsAction as below for each of the items which you want to display in action menu. android:showAsAction="withText"

- 707
- 8
- 11
actionBar = getActionBar();
// Hide the action bar title
actionBar.setDisplayShowTitleEnabled(false);
// Enabling Spinner dropdown navigation
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// Spinner title navigation data
navSpinner = new ArrayList<SpinnerNavItem>();
navSpinner.add(new SpinnerNavItem("Local", R.drawable.ic_location));
navSpinner.add(new SpinnerNavItem("My Places", R.drawable.ic_my_places));
navSpinner.add(new SpinnerNavItem("Checkins", R.drawable.ic_checkin));
navSpinner.add(new SpinnerNavItem("Latitude", R.drawable.ic_latitude));
// title drop down adapter
adapter = new TitleNavigationAdapter(getApplicationContext(), navSpinner);
// assigning the spinner navigation
actionBar.setListNavigationCallbacks(adapter, this);

- 55
- 1
- 5