动画Drawable-应用程序在向列表添加新行后停止工作

时间:2014-08-12 15:38:02

标签: android android-animation xml-drawable

我正在使用Animation Drawable为简单的Android游戏创建一种故事。按下"开始"按钮,出现一个带有跳过按钮的故事。一切正常,直到我将新照片添加到代表故事情节的照片列表中,整个应用程序停止工作&说:"不幸的是app已经停止"

这是我的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"));
                }
            });


    }

}

我该怎么办?还是有另一种方法可以创建动画Drawable吗?

0 个答案:

没有答案