TimerCount timer = new TimerCount(120000, 1000, tv_getcode);
timer.start();
public class TimerCount extends CountDownTimer {
private TextView getcode;
public TimerCount(long millisInFuture, long countDownInterval,
TextView bnt) {
super(millisInFuture, countDownInterval);
this.getcode = bnt;
}
public TimerCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
getcode.setClickable(true);
getcode.setText("获取验证码");
// initcode();
}
@Override
public void onTick(long arg0) {
getcode.setClickable(false);
getcode.setText(arg0 / 1000 + "秒");
}
}