我image
从服务器存储在一个Bitmap arrayList
,然后使用thread
等待3秒,切换图像。假设的大小arraylist
是3。然后在一个接一个地切换3个图像后,它又等待了3秒,但现在没有图像。再次从 0 开始循环。我不明白为什么这额外的 3 秒等待。
胎面代码是..
ImageSwitcher dailywear;
ArrayList<Bitmap> bitmapDailywear = new ArrayList<Bitmap>();
dailyWear.setImageDrawable(new BitmapDrawable(bitmapDailyWear.get(0)));
final Handler handler = new Handler();
final Runnable r = new Runnable() {
int i = 1;
public void run() {
dailyWear.setImageDrawable(new BitmapDrawable(bitmapDailyWear.get(i)));
i++;
if (i == bitmapDailyWear.size())
i = 0;
handler.postDelayed(this, 3000);
}
};
handler.postDelayed(r, 3000);