public class TimeCount extends CountDownTimer {
TextView textView;
public TimeCount(TextView textView) {
super(60000, 1000);//参数依次为总时长,和计时的时间间隔
this.textView = textView;
}
@Override
public void onFinish() {//计时完毕时触发
textView.setText("重新获取");
textView.setClickable(true);
}
@Override
public void onTick(long millisUntilFinished) {//计时过程显示
textView.setClickable(false);
textView.setText(millisUntilFinished / 1000 + "秒");
}
}
开启计时:
TimeCount timer = new TimeCount(textview);
timer.start();