Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Menu option in android

Tags:

android

After referring a lot of tutorials I came to know that instead of Menu they have ActionBar for > API 10. But i am using API 7 sdk for my testing, I have used Menus to show text with drawable images. But only the text is coming and the drawable icon image is not showing in the menu option. Please help me to solve this.

My XML:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <!--
             Single menu item
             Set id, icon and Title for each menu item
    -->
    <item
        android:id="@+id/savedstory"
        android:background="#000000"
        android:minHeight="20dp"
        android:title="Saved Stories"/>
    <item
        android:id="@+id/setting"
        android:background="#000000"
        android:minHeight="20dp"
        android:title="Settings"/>
    <item
        android:id="@+id/Bookmark"
        android:background="#000000"
        android:minHeight="20dp"
        android:title="Bookmark This"/>
    <item
        android:id="@+id/share"
        android:background="#000000"
        android:minHeight="20dp"
        android:title="Share This"/>
    <item
        android:id="@+id/save"
        android:background="#000000"
        android:minHeight="20dp"
        android:title="Save This"/>
    <item
        android:id="@+id/small"
        android:icon="@drawable/font3"
        android:minHeight="20dp">
This icon is not showing.
            />
        <item
            android:id="@+id/medium"
            android:background="#ffffff"
            android:minHeight="20dp"
            android:title="Medium font"/>
        <item
            android:id="@+id/big"
            android:background="#000000"
            android:minHeight="20dp"
            android:title="Big font"/>
    </item>

</menu>

My inflating code:

public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.newsdescriptionmenu, menu);
  return true;
}
like image 290
Subburaj Avatar asked Jan 03 '13 11:01

Subburaj


1 Answers

If you refer to Menu documentation"

Options menus: The icon menus do not support item check marks and only show the item's condensed title. The expanded menus (only available if six or more menu items are visible, reached via the 'More' item in the icon menu) do not show item icons, and item check marks are discouraged.

Since I cannot see how you inflate (what options, etc) your menus I can only assume that you don't see this item's icon as it is a sixth item and hits the expanded menu after 'More'.

like image 161
Marcin Gil Avatar answered Oct 18 '22 22:10

Marcin Gil