我是一名有用的助手,可以为您翻译文本。以下是需要翻译的内容:
这是我尝试运行它的代码:
我正在尝试为我的活动设置一个作为背景的图像视图的动画,但应用在加载活动时会崩溃。所有的图像和.xml文件都在drawable-hdpi文件夹中,所以我不确定为什么它找不到。请告诉我是否有更好的方法将动画设置为活动背景。
这是我的动画.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/bow1" android:duration="60" />
<item android:drawable="@drawable/bow2" android:duration="60" />
<item android:drawable="@drawable/bow3" android:duration="60" />
<item android:drawable="@drawable/bow4" android:duration="60" />
<item android:drawable="@drawable/bow5" android:duration="60" />
<item android:drawable="@drawable/bow6" android:duration="60" />
<item android:drawable="@drawable/bow7" android:duration="60" />
<item android:drawable="@drawable/bow8" android:duration="60" />
<item android:drawable="@drawable/bow9" android:duration="60" />
</animation-list>
这是我尝试运行它的代码:
这是我正在使用的代码:
public class MainActivity extends Activity {
ImageView bground;
AnimationDrawable bganim;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.activity_main);
bground = (ImageView)findViewById(R.id.background);
bground.setBackgroundResource(R.drawable.bowanimbg);
bganim = (AnimationDrawable) bground.getBackground();
bganim.start();
}
java.lang.RuntimeException:无法启动组件Activity ComponentInfo{com.example.lucidity/com.example.lucidity.MainActivity}:android.content.res.Resources$NotFoundException:从可绘制资源ID#0x7f02000b加载文件res/drawable-xxhdpi/bowanimbg.xml