Reputation: 33876
K So i am making a timer with CountDownTimer. it is my first app i am doing and i am already running into a problem. First my timer is skipping the number 14? no clue why. and second, I dont know how to set the proper format. "mm:ss" My biggest issue is setting format. I need to have it so when i get to 8 seconds left it read 00:08 etc. and when i have minute 15 left it read 1:15, and not 00:75 or 1:75. Its been a long day trying to figure this out. Thanks in advance.
private void walk() {
new CountDownTimer(15000, 1000) {
@Override
public void onFinish() {
lapCounter++;
lapNumber.setText("Lap Number: " + lapCounter);
run();
}
@Override
public void onTick(long millisUntilFinished) {
text.setText("Time left:" + millisUntilFinished/1000);
}
}.start();
Upvotes: 1
Views: 170
Reputation: 1
I usually set two different variables for the minutes and seconds and then subtract one from the minutes once the seconds reach zero and then reset the seconds , like so:
if(secs==0){
mins--
secs=60;
}
Upvotes: 0