使用CountDownTimer实现倒计时功能

 1 // 倒计时60s
 2         new CountDownTimer(60000, 1000) {
 3 
 4             @Override
 5             public void onTick(long millisUntilFinished) {
 6                 mReGetAuthCodeButton
 7                         .setText(getString(R.string.tip_get_code_time,
 8                                 millisUntilFinished / 1000));
 9 
10             }
11 
12             @Override
13             public void onFinish() {
14                 mBackAble = true;
15                 mReGetAuthCodeButton
16                         .setBackgroundResource(R.drawable.blue_button_selector);
17                 mReGetAuthCodeButton.setText(R.string.re_get_code);
18             }
19         }.start();

之前使用handler thread实现,发现非常影响其它view的响应,改为这个很好。

http://blog.csdn.net/yuanjh2001/article/details/6075315

原文地址:https://www.cnblogs.com/anee/p/3627920.html