Search code examples
androidandroid-menuoptionmenu

Why OptionMenu not show icon menu in 4.0 but work in 2.x.x


I try to create OptionMenu which application's target is 15 but minSDK is 8. I Have one Menu folder and mymenu.xml in it. I wanna use the default icon menu and wanna make it support since sdk 8. How should it do that? The problem when i test is, the option menu icon show only on sdkVersion 8 but, not show on sdkVersion 15

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@+id/my_menu" android:title="Send Mail" android:icon="@android:drawable/ic_menu_send"></item>
</menu>

and in Activity

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mymenu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.my_menu:
            //Do something
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

Solution

  • The action overflow -- what you are thinking of as the options menu on API Level 11+ -- does not show icons.