<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/test"
android:icon="#drawable/ic_lanucherxx.png" // error
android:title="#string/news"
android:showAsAction="ifRoom"/>
<item android:id="#+id/test2"
android:icon="#drawable/we.png" //error
android:title="#string/newss2"
android:showAsAction="ifRoom"/>
here is the xml file . the error says that there are no such images in the drawable folder . But i have made sure that that required images are present in all of those drawables folders .
Thank you for your time .
don't use extension .png
just remove it and try once i hope it solves your problem
Related
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 am creating a loading screen using animation-list but I've run into a error where I cannot get access to my res/drawable folders inside my xml file. The error I get is "No resource found that matches the given name (at 'drawable' with value '#drawable/loadingwave0.png')"
Inside the directory res/anim/ My xml code is simple:
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="#drawable/loadingwave0.png"
android:duration="100" />
</animation-list>
I've noticed that inside my item tag, Eclipse does not predict any drawable resources even though I've already copied them(not referenced) to the drawable folders(hdpi, ldpi, mdpi). My .png images can be accessed through my AndroidManifest.xml file if I use the code
<item android:icon="#drawable/loadingwave0.png"/>
for making sure the drawable folders can be accessed. I have already cleaned and refreshed my project multiple times.
Any help would be greatly appreciated.
you should use :
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="#drawable/loadingwave0"
android:duration="100" />
</animation-list>
the resource id is the file name without extension.
I've been getting an error in main.xml file which is in menu folder. R.java isn't generated. The error is on the last line of xml code. I have tried everything...
<?xml version="1.0" encoding="utf-8"?>
<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"/>
</menu>
Put this line in strings.xml inside /res/values directory
<string name="action_settings">Your String Here</string>
Well first of all, if you know basic html, you should know that every tag has an opening tag and a closing tag. That being said, in your code, you close the item tag but you forgot to closs the menu tag :-
<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"/>
</menu>
Cut your code from your xml-file and paste it in an normal text editor, notepad or gedit or something like this. Copy it back to your xml-file. Sometimes this helps.
I would like to change the expanded and default icon of my Expandable List View.
I did some research how to do this and found this question.
I think I did it just as it is described there.
I have 2 icons, the first is called defaulticon.png and the second one expandedicon.png. Bother are located in the drawable folder (not in drawable-hdpi).
My list view declaration looks like this:
<ExpandableListView
android:id="#+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:groupIndicator="#drawable/groupindicator">
</ExpandableListView>
The groupindicator is an xml file also located in the drawable folder and looks like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/defaulticon" android:state_empty="true"/>
<item android:drawable="#drawable/expandedicon" android:state_expanded="true"/>
</selector>
However the icons do not change. The default icon from the list view disappears and instead there is no icon.
Are there any restrictions with the resources (how big the resources can me (both are 160x160), where they have to be located,...).
I am testing the app on my S3 running Android 4.1.2.
Cheers
Change your icon size to 32 X 32, put your icon in drawable-mdpi and then try this code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/expandedicon" android:state_expanded="true"/>
<item android:drawable="#drawable/defaulticon"/>
</selector>
First of all, resize your image to 24*24 and then copy it to the drawable-mdpi folder in Android. After that, copy and paste this code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/abc"android:state_empty="true"></item>
<item android:drawable="#drawable/downarrow" ></item>
</selector>
Im creating an android app which uses a menu.xml file in the res folder. But I'm getting the above error. What does it mean? How can I fix it?
menu.xml:
<?xml version="1.0" encoding= "utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item id="#+id/my_location"
android:icon="#drawable/my_location"
android:title:="Current location" />
<item id="#+id/mapview_satellite"
android:icon="#drawable/satelliteview"
android:title="Satellite View" />
<item id="#+id/mapview_normal"
android:icon="#drawable/normalview"
android:title="Normal view" />
</menu>
Change <item id="#+id/my_location" to <item android:id="#+id/my_location". This in all three places.
Also, in here: android:title:="Current location" remove the colon after title.
You also need to make sure the following two lines are in your attributes list:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
If you omit those, Eclipse will just give you the "missing android prefix" error.
Believe it or not, for anyone who tries to work through examples in downloaded books, you may need to make sure you have true quotation marks as the compiler understands them. I'd been getting the same error as the OP, and many similar parse errors as I tried to modify an XML file in small ways. I noticed then that quote marks from the pasted code snippets were different from the ones on my keyboard (in the snippets they leaned to the right, and if I typed them myself they were straight up and down).
I know this sounds nuts and I could hardly believe it myself, but when I retyped my quotes it worked fine.
Adding android: before the attribute solved my problem.
create an XML file inside your project's res/menu/ directory Not in in res folder
&
dont forget to prefix the id attributes.
Try like this:
<?xml version="1.0" encoding= "utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/my_location"
android:icon="#drawable/my_location"
android:title="Current location" />
<item android:id="#+id/mapview_satellite"
android:icon="#drawable/satelliteview"
android:title="Satellite View" />
<item android:id="#+id/mapview_normal"
android:icon="#drawable/normalview"
android:title="Normal view" />
</menu>
Some times the XML code might be written correctly so you need to simply cut what you currently have and then delete it from the line numbers then re-paste it and the error should be fixed. If it doesn't then you know your code is wrong. The xml default is to recognize what you have put at first and needs to be removed in order to begin again. Trust me I just spent 3 days on that very problem and did exactly what is said above, good luck.
If you have something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="person" type="com.abc.PersonEntity"/>
</data>
Move your data inside layout tag:
<layout xmlns:android="http://schemas.android.com/apk/res/android" >
<data>
<variable name="person" type="com.abc.PersonEntity"/>
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
...
You've forgotten to prefix the id attributes. Try to do it like this:
<?xml version="1.0" encoding= "utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/my_location"
android:icon="#drawable/my_location"
android:title="Current location" />
<item android:id="#+id/mapview_satellite"
android:icon="#drawable/satelliteview"
android:title="Satellite View" />
<item android:id="#+id/mapview_normal"
android:icon="#drawable/normalview"
android:title="Normal view" />
</menu>
there was two error silly error
- id isn't it attribute is android:id
- First itme android:title:= you have written extra colon after title
here is implemented code
<?xml version="1.0" encoding= "utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/my_location"
android:icon="#drawable/my_location"
android:title="Current location"/>
<item
android:id="#+id/mapview_satellite"
android:icon="#drawable/satelliteview"
android:title="Satellite View"/>
<item
android:id="#+id/mapview_normal"
android:icon="#drawable/normalview"
android:title="Normal view"/>
</menu>