I'm following a book on Android Development to get myself started writing my first real app.
I got up to the point where I'm making an options menu for one of my activities. The menu shows up, but the corresponding icon of the menu item refuses to display.
Here is the code for the menu:
ReminderListActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.list_menu, menu);
return true;
}
res/menu/list_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_insert"
android:icon="@drawable/menu_add"
android:title="@string/menu_insert" />
</menu>
I have copied the ic_menu_add.png icon (32x32px) from one of my Android SDK subfolders to my res/drawable-mdpi folder and renamed the file to menu_add.png. I refreshed the folder within eclipse so the icon shows up, and as you can see I set it as the icon for the menu item in my layout file. I tried running my project in the emulator a few times, but the icon never shows up. For the record, I am using Android 4.0.3..
Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…