CountDownTimer in android - how to restart it

后端 未结 5 1420
攒了一身酷
攒了一身酷 2021-01-04 03:26

I to restart a CountDownTimer. I read a lot of question here but no one of the answer helped me. When I use the following code

if(Const.counter != null){
            


        
5条回答
  •  我在风中等你
    2021-01-04 04:23

    Just call again the start() method:

    CountDownTimer cdt = new CountDownTimer(30000, 1000) {
    
        public void onTick(long millisUntilFinished) {
            mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
        }
    
        public void onFinish() {
            this.start(); //start again the CountDownTimer
        }
    };
    

提交回复
热议问题