Is there a way to use progress bar with handler? I have the code below and I would like to include a progress bar that would "count down" the delay until the next loop. (in this case 2000ms).
private boolean started = false;
private Handler handler = new Handler();
private Runnable runnable = new Runnable() {
@Override
public void run() {
final Random random = new Random();
int i = random.nextInt(2 - 0 + 1) + 0;
random_note.setImageResource(image[i]);
if(started) {
start();
}
}
};
public void stop() {
started = false;
handler.removeCallbacks(runnable);
}
public void start() {
started = true;
handler.postDelayed(runnable, 2000);
}