简体   繁体   中英

No resource found that matches the given name, where I do something wrong?

I can't figure why I get this error :

no resource found that matches the given name

I have a folder called "anim" inside the Resources folder, inside the anim folder I have 2 files: slide_up.xml and slide_right.xml

Here is my style file :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowTitleSize">0dp</item>
  </style>  

<style name="DialogAnimation">
        <item name="android:windowEnterAnimation">@anim/slide_up</item>
        <item name="android:windowExitAnimation">@anim/slide_right</item>
</style>
</resources>

I am keep getting this error every time I am tiring to build the project, I am 100% sure that the file names and the path are correct, so why the project doesn't recognize the files ?

Edit : This is how I call the animation :

public override void OnActivityCreated (Bundle savedInstanceState)
{
    Dialog.Window.RequestFeature (WindowFeatures.NoTitle); //Sets the title bar to invisible
    base.OnActivityCreated (savedInstanceState);
    Dialog.Window.Attributes.WindowAnimations = Resource.Style.DialogAnimation; //Sets the animation
}

Thank you for helping me out but I have figured out the answer, its was pretty simple but I really have no idea why this happens because in every other place in the code everything works fine.

I found the answer here , by Stephen Wylie and I quote the answer :

"This problem appeared for me due to an error in an XML layout file. By changing @id/meid to @+id/meid (note the plus), I got it to work. If not, sometimes you just gotta go to Project -> Clean"

As soon as I added "+" to the "@anim/slide_up" so now its like "@+anim/slide_up" the code seems to work.

I posted this just in-case someone else will have the same struggle because I was trying to fix this for 5 hours now..

From API guides->animation resources->View animation: resource reference:In Java:

R.anim.filename

In XML:

@[package:]anim/filename

Maybe try adding the package?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM