2013-08-19 37 views
0

我想在我的应用程序中设置一个动画图像。我使用动画列表逐帧显示它,但它不工作! 请帮助我!我想在我的应用程序中设置一个动画图像

这里是Java代码

_imagView=(ImageView)findViewById(R.id.imageView1); 
_imagView.setBackgroundResource(R.drawable.anim); 
AnimationDrawable anim1 = (AnimationDrawable) _imagView.getBackground();  
anim1.start(); 

,这里是anim.xml

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:oneshot="false"> 
<item android:drawable="@drawable/animationchoking0" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking1" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking2" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking3" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking4" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking5" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking6" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking7" android:duration="500" /> 
<item android:drawable="@drawable/animationchoking8" android:duration="500" /> 
</animation-list> 

回答

0

根据该开发指南,你不应该直接拨打电话您的活动的onCreate()方法开始(Drawable Animation在底部)。试试这个:

_imagView.post(new Runnable() { 

     @Override 
     public void run() { 
      // TODO Auto-generated method stub 
      anim1.start(); 
     } 
    }); 
+0

非常感谢你,它工作。 – eli

相关问题