Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

menu

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.

like image 778
Kiran Gunda Avatar asked Nov 29 '11 06:11

Kiran Gunda


People also ask

How do I show the menu icon on Android?

Click res → New → Vector Asset . Choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”. 6- Now we can add android menu items with icons, we will have 4 menu items. 1 menu item will be the root while the other 3 menu items will be grouped under a single Menu .

What is MenuItem in android?

android.view.MenuItem. Interface for direct access to a previously created menu item. An Item is returned by calling one of the Menu. add(int) methods. For a feature set of specific menu types, see Menu .


1 Answers

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.

like image 68
Janusz Avatar answered Sep 20 '22 11:09

Janusz