我正在使用 Animation Drawable 为一个简单的 Android 游戏创建一种故事。按下“开始”按钮后,会出现一个带有跳过按钮的故事。一切正常,直到我将一张新照片添加到代表故事情节的照片列表中,整个应用程序停止工作并说:“不幸的是应用程序已停止”
这是我的 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="true">
<item android:drawable="@drawable/homeone" android:duration="50" />
<item android:drawable="@drawable/hometwo" android:duration="50" />
<item android:drawable="@drawable/homethree" android:duration="50" />
<item android:drawable="@drawable/homefour" android:duration="50" />
<item android:drawable="@drawable/homefive" android:duration="50" />
<item android:drawable="@drawable/homesix" android:duration="50" />
<item android:drawable="@drawable/homeseven" android:duration="50" />
<item android:drawable="@drawable/tableone" android:duration="50" />
<item android:drawable="@drawable/tabletwo" android:duration="50" />
<item android:drawable="@drawable/tablethree" android:duration="50" />
<item android:drawable="@drawable/tablefour" android:duration="50" />
<item android:drawable="@drawable/tablefive" android:duration="50" />
<item android:drawable="@drawable/tablesix" android:duration="50" />
//After adding the last line "tablesix", the app stop working
</animation-list>
这是我的 Java 文件:
package xx.tellme;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
public class StoryLine extends Activity{
ImageView story;
ImageButton skip;
AnimationDrawable anime;
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.stortlinelayout);
story = (ImageView) findViewById(R.id.imageView1);
skip = (ImageButton) findViewById(R.id.skipbut);
anime = new AnimationDrawable();
story.setBackgroundResource(R.drawable.dlist);
anime =(AnimationDrawable) story.getBackground();
anime.start();
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("xx.tellme.KAR"));
}
});
}
}
我该怎么办 ?还是有另一种方法来创建这个远离动画绘图?