Kiran Gunda
Kiran Gunda

Reputation: 73

Android menu icons are not displaying when the API level is above 10

I am trying to test something with menu options in Android.. And I noticed that menu icons are not displaying if the targetSdkVersion is greater than 10...

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
   <item android:id="@+id/about" android:title="@string/about_label"
   android:icon="@android:drawable/ic_menu_info_details" android:alphabeticShortcut="a" />
   <item android:id="@+id/help" android:title="@string/help_label"
   android:icon="@android:drawable/ic_menu_help" android:alphabeticShortcut="h" />
</menu>

I am trying to debug, and I am not sure where to start.

Upvotes: 6

Views: 8389

Answers (2)

shanta
shanta

Reputation: 11

<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"
    tools:context="com.ktcmynewapp.MainActivity" >

    <item
        android:id="@+id/action_settings1"
        android:icon="@drawable/image1"`enter code here`
        android:orderInCategory="100"
        android:title="home1"
        app:showAsAction="never">
        <menu>
            <item
                android:id="@+id/action_settings2"
                android:icon="@drawable/image2"
                android:orderInCategory="100"
                android:title="home1"
                app:showAsAction="never"/>
            <item
                android:id="@+id/action_settings3"
                android:icon="@drawable/image3"
                android:orderInCategory="100"
                android:title="home2"
                app:showAsAction="never"/>
        </menu>
    </item>
    <item
        android:id="@+id/action_settings4"
        android:icon="@drawable/image2"
        android:orderInCategory="100"
        android:title="home2"
        app:showAsAction="never"/>

</menu>

In this code the outer menu items are showing without icons, but the inner sub-menu items are properly showing with icons.

Upvotes: 1

Janusz
Janusz

Reputation: 189464

Starting with API Level 11 (Android Honeycomb) Android introduced a new concept for menus. Devices build for that API Level do not have a menu key anymore. Instead of showing a menu after a key is pressed there is a new UI Component: the Actionbar. The Actionbar now shows as much menu items as the space allows and after that creates a button that will show the rest of the menu items in an overlay.

I would assume that you are using some kind of theme for your activity that prevents the Actionbar from appearing and therefore no menu items are visible. Also read the guide on how to support Tablets and Handsets to begin to understand how the new actionbar works.

Upvotes: 7

Related Questions