Hosni
Hosni

Reputation: 668

android : option menu doesn't work correctly

i am trying to make an stylish option menu which with text and icons close to this:

but i am still getting this:

http://img651.imageshack.us/img651/3007/resultax.th.png

Here is my code:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actionb_menu, menu);

    return true;
}

The actionb_menu.xml

<?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" >

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

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

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

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

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

</menu>

any one can help please? any ideas hints??

Upvotes: 1

Views: 1893

Answers (3)

Navarr
Navarr

Reputation: 3764

Though this isn't an actual answer to your specific question, you might try going about this a different way.

What you get is the new type of Options Menu for Android ICS devices. What you say you want is the old style Options Menu from Pre-Honeycomb devices. Android is trying to phase this out however, along with the menu button.

Instead, It is recommended you use an ActionBar. The design details of the Action Bar are covered heavily on the Android Design website.

This would move your buttons up into the Top Bar, as it looks like you're already trying to do from your screenshot. You could either go through the difficult steps (that I don't know) to use ActionBar for newer devices and do something else for older devices - or you could use ActionBarSherlock to use the ActionBar for all Android devices. ActionBarSherlock's website has more details and instructions for setting it up, and their github has code and samples of it in use.

If instead what you want to do is truly get the old fashioned menu, you can change your TargetBuild to a lesser Android version. This is generally done in the properties for your project.

Upvotes: 1

Denat Hoxha
Denat Hoxha

Reputation: 945

Try replacing return true in your onCreateOptionsMenu implementation to return super.onCreateOptionsMenu(menu). The method should chain upwards.

Upvotes: 0

Orlymee
Orlymee

Reputation: 2357

What you are seeing is how settings menu appears on ICS Android 4.0.

Check your target platform and change it to 2.3.3.

Upvotes: 0

Related Questions