Android 倒计时CountDownTimer 的使用
/** * 倒计时类 * * @author tab */ public class TimerDownTab extends CountDownTimer { private TimerDownListener listener; public interface TimerDownListener { void onTick(long millis); void onFinish(); } public void setOnTimerDownListener(TimerDownListener listener) { this.listener = listener; } /** * @param millisInFuture 总时间 * @param countDownInterval 间隔跳动时间 */ public TimerDownTab(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onTick(long millisUntilFinished) { if (listener != null) { listener.onTick(millisUntilFinished); } } @Override public void onFinish() { if (listener != null) { listener.onFinish(); } } }