/定义一个倒计时的内部类/
class CountDown extends CountDownTimer {
public CountDown(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish()
{
mShowTest.setText("finish");
}
@Override
public void onTick(long millisUntilFinished)
{
mShowTest.setText("0" + millisUntilFinished / 60000 + ":" + (millisUntilFinished % 60000 /1000) + ":" + (millisUntilFinished % 60000 % 100));
}
}
调用如下:第一个参数是倒计时的时间,第二个参数是时间间隔
CountDown mCountDown = new CountDown (3 * 60 * 1000, 10);
mCountDown .start();