我想在我的imageView中显示多个图像我想通过使用for循环来执行此操作,但我的图像视图仅显示最后一个图像。
我也尝试过Thread.sleep和sleep函数,但是它们没有用
for(int i=0;i<=3;i++){
try {
pic = picText.getText().toString();
String photoPath = "sdcard/Pictures/" + pic + i + ".jpg";
imageView.setImageBitmap(BitmapFactory.decodeFile(photoPath));
sleep(1000);
} catch (Exception ex) {
}}
我希望一个接一个地获得所有图像,延迟是在sleep()函数中给出的。
使用Thread.sleep(1000)
暂停执行当前线程指定的时间(以毫秒为单位)。
获取数组或ArrayList中的所有imagepath,然后使用handler和timertask
定时器t;处理程序处理程序可运行的更新; handler = new Handler(); update = new Runnable(){@ Override public void run(){
//load photo } }; t = new Timer(); t.schedule(new TimerTask() { @Override public void run() { handler.post(update); } }, 0, 5000);
Note if its showing last image, redirect counter to 1st image. Hope this helps