我在模擬Frame Animation;我有這一切工作都有一個問題。 我有一個for循環,其中,在每次迭代中,它會延遲一段時間後更改ImageView的圖像。在循環中創建唯一的postDelayed Runnables
for(int i = 1; i <13; i++){
if (stop== false){
String imgName = "b"+ Integer.toString(i);
id = getResources().getIdentifier(imgName, "drawable", getPackageName());
Handler handlerTimer = new Handler();
handlerTimer.postDelayed(new Runnable(){
public void run() {
view.setImageDrawable((getResources().getDrawable(id)));
}}, 300);
}
}
問題是run()不會在每次迭代時刷新;它只能工作一次。
我該如何刷新或進行新的運行()?
我接受任何其他方式來做到這一點。
任何意見,將不勝感激。
我不工作。我試着放置view.invalidate();在運行之外,它也沒有在那裏工作。 –
您是否嘗試過使用線程而不是您使用的處理程序?如果你需要的話,我可以給你一個例子。 – gsfd
是的,你能舉個例子嗎? –