Android image (slide)show without images sliding, just changing
<p>I'm trying to make an image slideshow for android. What I want for it is a play and pause button, restart button and a previous image button. And a seek bar for changing the speed the image change. 
At the moment I have the file names of the images stored in a database and the images on the sd-card. Then, for each image have some text in the database that I want to load in to a textview at the same time as the image change. </p>

<p>This is what I've done which almost works. It starts to play but stops after one or two picture. And the buttons above doesn't work including the seekbar. 
I know this might not be the most sophisticated code but if you know how to solve my problems or have suggestions of how to make it better, I'd be greatfull. </p>

<pre><code>private ImageView image = null;
private TextView title = null;
private SeekBar speed = null;
private Button play = null, done = null, restart = null, previous = null;
private Cursor cursor = null;
private DBase db = null;
private int theSpeed = 900;
private boolean isPlaying = false;
private CountDownTimer show;
private int i = 0, frames = 0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image);

    image = (ImageView) findViewById(R.id.imageView11);
    title = (TextView) findViewById(R.id.textView11);
    speed = (SeekBar) findViewById(R.id.seekBar11);
    play = (Button) findViewById(R.id.button21);
    done = (Button) findViewById(R.id.button22);
    restart = (Button) findViewById(R.id.button23);
    previous = (Button) findViewById(R.id.button24);

    speed.setOnSeekBarChangeListener(this);
    play.setOnClickListener(this);
    done.setOnClickListener(this);
    restart.setOnClickListener(this);
    previous.setOnClickListener(this);

    db = new DBase(this);
    db.open();

    SharedPreferences prefs = getPreferences(MODE_PRIVATE);

    cursor = db.getAll();
    startManagingCursor(cursor);
    frames = cursor.getCount();
    if (frames != 0) {
        cursor.moveToFirst();
        if (cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)) != null){
            setImage(cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)));
            setTitle(cursor.getString(cursor.getColumnIndexOrThrow(DBase._date)),cursor.getString(cursor.getColumnIndexOrThrow(DBase._text)));
            if (cursor.moveToNext()) theShow(theSpeed);
            isPlaying = true;
        }
    }
}



private void setImage(String photo) {
    try {
        String path = "/sdcard/App/";
        FileInputStream fis = new FileInputStream(path + photo);
        Bitmap bitmap = BitmapFactory.decodeStream(fis);
        image.setImageBitmap(bitmap);
    } catch (Exception e) {

    }
}

private void theShow(int speed) {
    show = new CountDownTimer(speed, 1000) {
        public void onTick(long millisUntilFinished) { }
        public void onFinish() {
            if (cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)) != null){
                setImage(cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)));
                setTitle(cursor.getString(cursor.getColumnIndexOrThrow(DBase._date)),cursor.getString(cursor.getColumnIndexOrThrow(DBase._text)));
                isPlaying = true;
                play.setText(getText(R.string.pause).toString());
                if (i &lt;= frames) {
                    i++;
                    show.start();
                }
            }
        }
    }.start();
}

@Override
public void onClick(View arg0) {
    switch (arg0.getId()) {
    case R.id.button21:
        //PLAY/PAUSE Button
        if (isPlaying) {
            show.cancel();
            isPlaying = false;
            play.setText(getText(R.string.play).toString());
        } else {
            theShow(theSpeed);
            isPlaying = true;
            play.setText(getText(R.string.pause).toString());
        }
        show.cancel();
        break;
    case R.id.button22:
        //EXIT Button
        this.finish();
        break;
    case R.id.button23:
        //RESTART Button
        cursor.moveToFirst();
        i = 0;
        if (cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)) != null){
            setImage(cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)));
            setTitle(cursor.getString(cursor.getColumnIndexOrThrow(DBase._date)),cursor.getString(cursor.getColumnIndexOrThrow(DBase._text)));
            if (cursor.moveToNext()) theShow(theSpeed);
        }
        break;
    case R.id.button24:
        //SHOW PREVIOUS IMAGE + PAUSE
        if (cursor.moveToPrevious()) {
            if (cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)) != null){
                setImage(cursor.getString(cursor.getColumnIndexOrThrow(DBase._photo)));
                setTitle(cursor.getString(cursor.getColumnIndexOrThrow(DBase._date)),cursor.getString(cursor.getColumnIndexOrThrow(DBase._text)));
                if (isPlaying) {
                    show.cancel();
                    isPlaying = false;
                    play.setText(getText(R.string.play).toString());
                }
            }
        }
        break;
    }

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (progress == 0 ) theSpeed = 2000;
    if (progress == 1 ) theSpeed = 1500;
    if (progress == 2 ) theSpeed = 1200;
    if (progress == 3 ) theSpeed = 900;
    if (progress == 4 ) theSpeed = 600;
    if (progress == 5 ) theSpeed = 300;
    theShow(theSpeed);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) { }

@Override
public void onStopTrackingTouch(SeekBar seekBar) { }

@Override
public void onDestroy() {
    super.onDestroy();
    cursor.close();
    db.close();
}
</code></pre>

<p>//André</p>
