我在,我想兩個動畫同時運行的應用程序的工作,但它不工作.... 我的代碼如下....幀動畫不能正常工作
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>
請在這裏發佈logcat。 –
它沒有顯示任何東西..... – Ashishsingh
顯示您的AnimationDrawable! –