用到CountDownTimer这个类,非常简单,只有四个方法,
public final void cancel () //取消后,再次启动会重新开始倒计时
public abstract void onFinish ()
public abstract void onTick (long millisUntilFinished) //onTick的调用是同步的,保证这次调用不会在之前调用完成前发生
public synchronized final CountDownTimer start ()

实例

1         new CountDownTimer(60 * 1000, 1000) {  
2             public void onTick(long millisUntilFinished) {  
3                 testView.setText("seconds remaining: " + millisUntilFinished / 1000);  
4             }  
5             public void onFinish() {  
6                 testView.setText("done!");  
7             }  
8          }.start();  

 

版权声明:本文为WangKangReg原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/WangKangReg/p/4249254.html