12
我處於我想從動態圖像列表中顯示動畫的情況。我想用AnimationDrawable用於此目的,但不幸的是我堅持... :(我的代碼是AnimationDrawable沒有動畫列表xml
ImageView globe = (ImageView) findViewById(R.id.globe);
AnimationDrawable animation = new AnimationDrawable();
animation.setOneShot(true);
Resources res = this.getResources();
while (from <= to) {
String name = "globe_" + String.format("%03d", from);
int globeId = res.getIdentifier(name, "drawable",
this.getPackageName());
animation.addFrame(res.getDrawable(globeId), 200);
from++;
}
globe.setBackgroundDrawable(animation);
globe.post(new Runnable(){
@Override
public void run() {
animation.start();
}
});
感謝您的答覆,但我已經將通過animation.addFrame提拉(res.getDrawable(globeId),200);我也試過你的方式,但沒有運氣:( – makki 2012-04-14 06:22:10
對不起,請看看這個linke,告訴我它是怎麼回事:http://androidforums.com/application-development/11620-programmatic-frame-frame - 動畫 - examle-animationdrawable.html – 2012-04-14 06:30:09