</pre><pre name="code" class="java"><pre name="code" class="java">private int seconds;
private Timer timer;
private void countdown() {// 倒计时
timer = new Timer();
seconds = 5;
final TimerTask showTime = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
PhoneNumberActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
if (seconds > 0) {
time.setText(seconds + "");
seconds--;
} else if (seconds == 0) {
showAnimation(103);
timer.cancel();
// timer = new Timer();
// isCountdown = false;
seconds--;
}
}
});
}
};
timer.schedule(showTime, 0, 1000);
}
用于注册时候倒计时 时间到了 再次显示发送验证码按钮
2.计时器