您的位置:首页 > 其它

CountDownTimer官方介绍和使用

2015-08-19 11:03 375 查看


Class Overview

Schedule a countdown until a time in the future, with regular notifications on intervals along the way. Example of showing a 30 second countdown in a text field:

上面的意思:安排一个倒计时器用于倒计时到未来的一个时间,在这个时间沿途中会间隔的定期通知你要做的时间。下面是展示的是30秒倒计时文本。

new CountDownTimer(30000, 1000) {

public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}

public void onFinish() {
mTextField.setText("done!");
}
}.start();

The calls to
onTick(long)
are
synchronized to this object so that one call to
onTick(long)
won't
ever occur before the previous callback is complete. This is only relevant when the implementation of
onTick(long)
takes
an amount of time to execute that is significant compared to the countdown interval.

上面的意思是,onTick的方法是对对象同步的,所以当这个上个onTick回调方法结束以后当前的onTick才起作用。onTick跟这个类唯一的相关是onTick的实现需要花大量的时间,这比倒计时Coutdown interval来说更加显著。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: