I am making a menu for an app and was pointed to this useful resource which lists all the drawables that are part of the android 2.0 jar. the usage example given is
myMenuItem.setIcon(android.R.drawable.ic_menu_save);
Unfortunately, the one I want (and most of the list) are not available by default. I get
android.R.drawable.ic_menu_login cannot be resolved
when I try to set the menu item images:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Add two example menu buttons
int groupId = 0;
int menuItemOrder = Menu.NONE;
int menuItemId = 1;
String menuItemText = "Add Login Details";
MenuItem menuItem = menu.add(groupId, menuItemId, menuItemOrder, menuItemText);
menuItem.setIcon(android.R.drawable.ic_menu_login )
Did something change in recent android releases? It seems that most of these are now 'private resources'... couldn't find much info on this but I found some advice:
It is used to access private resources. Do not use it because these private resources are often removed/renamed/etc. Using it would most likely break your app in the future.
Why would they change the resource names anyway? (The images behind them sure, but the names?) How do I access ic_menu_login
then? Is there a better reason not to than the above?
How do I access ic_menu_login then?
Copy it into your application. You can find all of them in your SDK installation, specifically in $ANDROID_HOME/platforms/$API/data/res/
, where $ANDROID_HOME
is wherever you installed the SDK and $API
is some Android level (e.g., android-2.1
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With