I have this menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/refresh" android:title="Actualizar" android:icon="#android:drawable/ic_menu_refresh"></item>
<item android:title="Sair" android:id="#+id/exit" android:icon="#android:drawable/ic_menu_close_clear_cancel"></item></menu>
and i'm getting this error:
Error: Resource is not public. (at 'icon' with value '#android:drawable/ic_menu_refresh').
Why the resource is not public? I have this icon in other apps and worked.
Maybe it's protected. In some API level, some icons are allowed to use, some are not. You can try ic_menu_home ic_menu_preferences ic_menu_help
Some links to refer:
http://groups.google.com/group/android-developers/browse_thread/thread/dabbe62aa1b54c13
android: resource not found
Related
I am new to android and am following this one tutorial pdf guide.
so far ive not found many unfixable errors.
except when i tried creating a folder in manifest of type menu and created menu_main.xml.
i get attribute is missing from the android name space prefix and a bunch other errors like unexpected text found in layout..
here is the code i pasted from the book. to the menu_main.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Our add icon will have its own button -->
<item android﹕id="#+id/action_add"
android﹕icon="#drawable/ic_add_white_24dp"
android﹕title="#string/action_add"
app﹕showAsAction="ifRoom" />
</menu>
Turns out all I had to do was delete the colons and re-type them because the spacing between the android:something was a little out of normal.
I had this menu xml that works fine:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="#+id/context_menu_save"
android:actionViewClass="my.app.TextViewPlus"
android:showAsAction="always"
android:title="#string/logout"
android:visible="false"/>
</menu>
But when i started using AppComap v7 i hade null exception when using getActionView().
I change my menu layout to:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/context_menu_save"
myapp:actionViewClass="my.app.TextViewPlus"
myapp:showAsAction="always"
android:title="#string/logout"
android:visible="false"/>
</menu>
And now it works fine. Can anyone explain, why is it happens?
xmlns:myapp this is used when you create your own (or use others) customized views.
xmlns:android this is used when default android views.
so as ur question, i hope ur using your own (or use others) customized views. so u got error.
In Android Studio v1.5, I see the following message for this scenario:
When using the appcompat library, menu resources should refer to the app: namespace, not the android: namespace.
When not using the appcompat library, you should be using the android: namespace.
I'm using ActionBarSherlock and HoloEverywhere in this project. The Main.xml is pretty simple and looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="#string/action_info_settings"
android:icon="#android:drawable/ic_menu_customsettings"/>
</menu>
I have ic_menu_customsettings.png in drawable-mdpi, drawable-hdpi, and drawable-xhdpi. I'm getting the following error:
Error: No resource found that matches the given name (at 'icon' with value '#android:drawable/ic_menu_customsettings').
Am I supposed to do something more than put the png files in those folders to make them accessible by the ActionBar?
The correct line is:
android:icon="#drawable/ic_menu_customsettings"/>
I am beginning android development and I am having problems making an action bar. Basically I am following some code form online and I am getting an error saying I do not have an icon:
error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_menu_search').
I did some research and thought my problem was I did not have all the extras downloaded from the android SDK. But after downloading all the extras it didnt work. I know I could just find the icon and download it, but I do not want to have to download all the icons individually, therefore I think I am missing something. My xml file I am getting the error with looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="#string/action_settings"/>
<item android:id="#+id/menu_search"
android:title="#string/menu_search"
android:icon="#drawable/ic_menu_search"
android:showAsAction="ifRoom|collapseActionView"
android:actionViewClass="android.widget.SearchView" />
</menu>
this is under menu>main.xml
If you want to use the android icon, you should add the android prefix after #. Change
#drawable/ic_menu_search
in
#android:drawable/ic_menu_search
#drawable looks inside the res/drawable* folder of your app. If you want to access to the android resources. strings/drawable/id you have to put the android prefix after the #. with that prefix you will access to the android.R class not to your.R class
I have the below XML in slider_button.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="#android:drawable/button9patch" />
...
</selector>
The android:drawable="#android:drawable/button9patch" gets the error:
Error: No resource found that matches the given name (at 'drawable'
with value '#android:drawable/button9patch').
However I think I have the file in the right place (I've even put it in all the drawable folders to be sure):
What am I doing wrong? Thanks
change like this
android:drawable="#drawable/button9patch"