I have a CountDown timer that counts from 10,000 ms to 0 ms in 1 second increments to make the button pressed after 10 seconds. Although the timer is accurate and does what the code says, I would like to change the way seconds are expressed, but I don't know how to do it.
Java:
void startTimer() { cTimer = new CountDownTimer(10000, 1000) { public void onTick(long millisUntilFinished) { c.setText("Please wait " + millisUntilFinished/1000 + " seconds"); thx.setText(millisUntilFinished/1000 + ""); thx.setAlpha(.5f); thx.setClickable(false); } public void onFinish() { c.setText("done"); thx.setText("ready"); thx.setAlpha(1f); thx.setClickable(true); } }; cTimer.start(); }
It is output (every second): 9, 8, 7, 6, 5, 4, 3, 2, 1, (still 1), ready
Desired: (every second): 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, ready
Thanks,
IN
EDIT:
I added 1 to the countdown, thx.setText(((millisUntilFinished/1000) + 1) + "");
New output: 10, 9, 8, 7, 6, 5, 4 ,3 , 2, (Still 2), ready
Closer ... but not quite.