Hosni
Hosni

Reputation: 668

customizing onOptionMenu look

i am trying to make my OnOptionMenu looks like this:

Any ideas on how to make it close to it??

Edit:

here is what i did:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
         android:id="@+id/item1"
         android:title="ajouter"
         android:icon="@drawable/ic_action_plus" 
         android:showAsAction="always">

    </item>
    <item 
        android:id="@+id/item2" 
        android:title="rechercher" 
        android:icon="@drawable/ic_action_loupe" 
        android:showAsAction="always">

    </item>
    <item 
        android:id="@+id/item3" 
        android:title="editer" 
        android:icon="@drawable/ic_action_crayon" 
        android:showAsAction="ifRoom">

    </item>
    <item 
        android:id="@+id/item4" 
        android:title="supprimer" 
        android:icon="@drawable/ic_action_poubelle" 
        android:showAsAction="ifRoom">

    </item>
    <item 
        android:id="@+id/item5" 
        android:title="à propos"  
        android:showAsAction="ifRoom" 
        android:icon="@drawable/ic_action_poubelle">

    </item>
    <item 
        android:id="@+id/item6" 
        android:title="Quitter"  
        android:showAsAction="ifRoom" 
        android:icon="@drawable/ic_action_poubelle">

    </item>

    </menu>

but it still looks the same, i still get a quiet classic menu.( just the item's title on a list)

here is how it looks: http://img651.imageshack.us/img651/3007/resultax.th.png

by the way do i have to inflate the actionbar menu and the menu on the bottom with two different inflaters??

any additional ideas??

Upvotes: 0

Views: 537

Answers (2)

Arif Nadeem
Arif Nadeem

Reputation: 8604

It is very easy, you can do this in xml file itself

<menu
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/Non_Veg"
android:title="Non Veg"
android:icon="@drawable/hamburger">  
 <menu>
        <item 
        android:id="@+id/Chicken"
              android:title="Chicken"/>
        <item 
        android:id="@+id/Butter_Chicken"
              android:title="Butter Chicken" />
        <item 
        android:id="@+id/Mutton"
              android:title="Mutton" />
        <item 
        android:id="@+id/Beef"
              android:title="Beef" />
        <item 
        android:id="@+id/Ham"
              android:title="Ham" />
    </menu>
 </item>
 </menu>

Here in item tag you can directly use the android:icon property to set the icon of the menu, hope I helped.

Upvotes: 0

Roman Black
Roman Black

Reputation: 3497

Create resource file in res/menu and inflate it in onCreateOptionsMenu() Activity-method

<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/help"
    android:title="Help" 
    android:icon="@drawable/ic_1/>
  <item android:id="@+id/keyboard"
    android:title="Keyboard"
    android:icon="@drawable/ic_2" />
  <item android:id="@+id/exit"
    android:title="Exit" 
    android:icon="@drawable/ic_3/>
</menu>

Upvotes: 1

Related Questions