Sabbir Ahmed Sabbir Ahmed - 3 months ago 17
Android Question

How to make a countdown Timer in android?

I have two edit texts in xml, In one edittext user can put a number as minute and in another one as seconds. After clicking the finish button the seconds edittext should start to countdown and updating its text every second. Aditionally how can I keep this updating until it comes into zero minutes zero seconds?

Answer
new CountDownTimer(30000, 1000) {

    public void onTick(long millisUntilFinished) {
        mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
       //here you can have your logic to set text to edittext
    }

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

}.start();

Refer to this link.

Comments