You should restart your Handler.postDelayed
inside the runnable to make it work.
Something like:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
private boolean useDiceOne;
@Override
public void run() {
ImageView image = (ImageView)findViewById(R.id.imgView_dice0);
if (!useDiceOne) {
image.setImageResource(R.drawable.dice_6);
} else {
image.setImageResource(R.drawable.dice_1);
}
useDiceOne = !useDiceOne;
handler.postDelayed(this, 3000);
}
}, 3000);
useDiceOne
will be used to change the image between dice_1
and dice_6
p.s cache the ImageView
.
To make it more flexible (stop it when you want, etc.) you could save the handler reference (and runnable reference too) somewhere and use removeCallbacks