Is there a way to display a set of images sequentially with play back features? I was wondering if this is possible to be done on an imageview or videoview?
Asked
Active
Viewed 411 times
0
-
PlayBack means? Do you want to show the pictures in slide show? – Shajeel Afzal Sep 12 '13 at 09:56
-
use timer and update your imageview from timer, set time your want in schedule task – Biraj Zalavadia Sep 12 '13 at 09:59
-
@BirajZalavadia can you elaborate a bit more on it please? – Mr.Noob Sep 12 '13 at 10:00
-
@ShajeelAfzal playback as in to forward and rewind like in a movie? – Mr.Noob Sep 12 '13 at 10:01
-
images from where server or sdcard? – Biraj Zalavadia Sep 12 '13 at 10:03
-
@BirajZalavadia images from an SDCARD – Mr.Noob Sep 12 '13 at 10:05
-
so you have the list of imagpath of sdcard and you want to show like slide show right? – Biraj Zalavadia Sep 12 '13 at 10:06
3 Answers
1
In your Activity
Timer myTimer;
String image[]; // array of imagePath
private int imagePostion;
class MyTimerTask extends TimerTask {
public void run() {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (++imagePostion == image.length) {
imagePostion = 0;
}
imgView.setImageBitmap(BitmapFactory.decodeFile(image[imagePostion]));
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
// change image every 2 seconds
public void startTimerTask() {
MyTimerTask myTask = new MyTimerTask();
myTimer = new Timer();
myTimer.schedule(myTask, 0, 2000);
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
image = {} // fille array with filePath
}
@Override
public void onPause() {
super.onPause();
try {
myTimer.cancel();
} catch (Exception e) {
e.printStackTrace();
}
}
// start slide show
@Override
public void onResume() {
super.onResume();
startTimerTask(); // start slide show
}

Biraj Zalavadia
- 28,348
- 10
- 61
- 77
-
-
what would be the initial value of imagePosition? sorry for the newb question – Mr.Noob Sep 16 '13 at 14:34
-
0
I have achieved the pictures playback using a ViewPager
and i have already answered this here on SO.
Although i have used the following technique to switch fragments
but you can inflate images in the fragment
:
You can check my answer on the following link:

Community
- 1
- 1

Shajeel Afzal
- 5,913
- 6
- 43
- 70