Katherine99
Katherine99

Reputation: 990

Android: CountDownTimer not working

I'm trying to create a countdown timer for my app but after doing this, the TextView where it should show the remaining time doesn't show anything so my timer is not working. I don't know if I am missed something.

Here is my timer:

 setContentView(R.layout.layout7);
         cronometro = (TextView) findViewById(R.id.cronometro);
         new CountDownTimer(60000, 1000) {

                public void onTick(long millisUntilFinished) {
                    cronometro.setText(Long.toString(millisUntilFinished / 1000));
                }

                public void onFinish() {
                   cronometro.setText("done!"); 
                }
             }.start();

Edit: As Simon said and changing some things the timer works now. Is there a way of setting the format into MM:SS

Upvotes: 1

Views: 978

Answers (1)

mango
mango

Reputation: 5636

cronometro.setText(DateUtils.formatElapsedTime(millisUntilFinished/1000));

Upvotes: 2

Related Questions