Android has a horizontal progress bar. I need to do this in 60 seconds.
Why is this code not working?
int progress = 0; progressBarHorizontal.setMax(60); while(progress < 60) { progressHandler.postDelayed((new Runnable() { public void run() { progressBarHorizontal.setProgress(progress); } }),progress * 1000); progress++; }
Please suggest other methods. I tried this:
new Thread(new Runnable() { int progress = 0; public void run() { long timerEnd = System.currentTimeMillis() + 60 * 1000; while (timerEnd > System.currentTimeMillis() ) { progress = (int) (timerEnd - System.currentTimeMillis()) / 1000;
But it doesnβt work either.
The second part of the code really works, the problem was in my logic.
source share