Java 找不到xml文件动画的符号

Java 找不到xml文件动画的符号,java,android-studio,android-animation,Java,Android Studio,Android Animation,我需要帮助。它说: 错误:找不到符号fruitImage.setBackgroundResource(R.drawable.myfruits); ^ 符号:可变myfruits 地点:可拉拔类 ----------------------这是密码---------------------- myfruits.xml (located at drawable) <?xmlversion="1.0"encoding="utf-8"?> <a

我需要帮助。它说: 错误:找不到符号fruitImage.setBackgroundResource(R.drawable.myfruits); ^ 符号:可变myfruits 地点:可拉拔类

----------------------这是密码----------------------

myfruits.xml (located at drawable)

<?xmlversion="1.0"encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/img_grapes" android:duration="200"/>
<item android:drawable="@drawable/img_lemon" android:duration="200"/>
<item android:drawable="@drawable/img_orange" android:duration="200"/>
<item android:drawable="@drawable/img_pear" android:duration="200"/>
<item android:drawable="@drawable/img_strawberry" android:duration="200"/>
</animation-list>

这是解释

在代码中,必须更改myfruits.xml

<animation-list android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/img_grapes" android:duration="200"/>
<item android:drawable="@drawable/img_lemon" android:duration="200"/>
<item android:drawable="@drawable/img_orange" android:duration="200"/>
<item android:drawable="@drawable/img_pear" android:duration="200"/>
<item android:drawable="@drawable/img_strawberry" android:duration="200"/>
</animation-list>

对我刚刚解决了我自己的问题。我创建了一个名为“anim”的新xml文件,将myfruits中的xml代码复制并粘贴到新文件中,它就可以工作了。谢谢
<animation-list android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/img_grapes" android:duration="200"/>
<item android:drawable="@drawable/img_lemon" android:duration="200"/>
<item android:drawable="@drawable/img_orange" android:duration="200"/>
<item android:drawable="@drawable/img_pear" android:duration="200"/>
<item android:drawable="@drawable/img_strawberry" android:duration="200"/>
</animation-list>
ImageView fruitImage = (ImageView) findViewById(R.id.imgFruit);
fruitImage.setBackgroundResource(R.drawable.myfruits);
AnimationDrawable fruitAnimation = (AnimationDrawable) fruitImage.getBackground();
fruitAnimation.start();