我正在开发我想同时运行两帧动画但它不工作的应用程序......我的代码如下......
ImageView Background, planet, info;
AnimationDrawable infoview, backgroundview;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Background = (ImageView) findViewById(R.id.imageView1);
planet = (ImageView) findViewById(R.id.planet);
//Background.setImageResource(R.drawable.friend_night_sky_31000);
Log.w("debug", "planetanimation started");
planetStart(R.drawable.earth, R.drawable.background);
Log.w("debug", "planetanimation stoped");
info = (ImageView) findViewById(R.id.info);
info.setImageResource(R.drawable.earthinfo);
Log.w("DEBUG", "which is null:image " + infoview + "or" + backgroundview);
}
public void planetStart(final int pid, final int bid){
Thread timer = new Thread(){
@Override
public void run(){
try{
//Thread.sleep(time);
} catch (Exception e){
} finally{
Infoview.this.runOnUiThread(new Runnable(){
public void run(){
planet.setBackgroundResource(pid);
infoview = (AnimationDrawable) planet.getBackground();
infoview.start();
Background.setBackgroundResource(bid);
backgroundview = (AnimationDrawable) Background.getBackground();
backgroundview.start();
Log.w("DEBUG", "which is null:image " + infoview + "or" + backgroundview);
}
});
}
}
};
timer.start();
}
任何人都可以帮助我为什么它不起作用?
Edit1我的地球文件如下
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:drawable="@drawable/earthframe1" android:duration="150" />
<item android:drawable="@drawable/earthframe2" android:duration="150" />
<item android:drawable="@drawable/earthframe3" android:duration="150" />
<item android:drawable="@drawable/earthframe4" android:duration="150" />
<item android:drawable="@drawable/earthframe5" android:duration="150" />
<item android:drawable="@drawable/earthframe6" android:duration="150" />
<item android:drawable="@drawable/earthframe7" android:duration="150" />
<item android:drawable="@drawable/earthframe8" android:duration="150" />
<item android:drawable="@drawable/earthframe9" android:duration="150" />
</animation-list>
bg文件如下
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/bg_1" android:duration="150" />
<item android:drawable="@drawable/bgimage2" android:duration="150" />
<item android:drawable="@drawable/bgimage03" android:duration="150" />
<item android:drawable="@drawable/bgimage4" android:duration="150" />
<item android:drawable="@drawable/bgimage5" android:duration="150" />
</animation-list>