Reputation: 405
Background: I am using Eclipse to develop an Android app. I have an xml file that contains a menu that contains three items. Each of the items contains an android:icon declaration. Only the first android:icon declaration is referenced in my program. NOTE: The second two android:icon declarations are NOT referenced ANYWHERE in my program or in any of the project files.
The Problem: I tried in vain to add a fourth menu item and discovered something very baffling to me. Not only cannot I not add an item to my menu, I cannot alter the existing last two android:icon declarations or I get the errors described in the title. For example I cannot change the following android:icon declaration from:
android:icon="@android:drawable/ic_menu_preferences"
To:
android:icon="@android:drawable/ic_menu_preference"
I find this very baffling because the android:icon is declared but not referenced anywhere in my program or in any of the project files. And none of the "solutions" I found on the internet fix my problem. And as I write this Stackoverflow is telling me my question has been asked and answered, but it hasn't!
Any ideas anyone?
Upvotes: 0
Views: 7603
Reputation: 12410
The line @android:drawable/ic_menu_preferences
is actually a reference itself. It is referencing a standard Android image that is displayed on your menu item. Here is some documentation to help you with drawables.
Upvotes: 2
Reputation: 24181
i think , you have added a png file which is corrupted
follow this link , probably it will help you
Upvotes: 1
Reputation: 1007099
NOTE: The second two android:icon declarations are NOT referenced ANYWHERE in my program or in any of the project files
They are in your menu. Otherwise, the android:icon
attributes would not exist. Hence, the icons are referenced by the menu itself.
For example I cannot change the following android:icon declaration
That is because there is no icon in the OS with that name.
Also, unless every icon you use in your menu will come from the OS, you are better served by copying them from your SDK into your project. Some OEMs replace the standard icons with their own versions. If you will be mixing OS icons with your own icons, even if you design your icons to match those on, say, the emulator, they will not match on other devices. By copying the icons from the SDK into your project, you ensure consistency within your menu -- if the icons look right on the emulator, they will look the same on other devices.
I find this very baffling because the android:icon is declared but not referenced anywhere in my program or in any of the project files.
The icon is part of the menu. Otherwise, the android:icon
attribute would not exist. Hence, the non-existent icon is referenced by the menu itself.
Upvotes: 5