我想在android中写一个倒计时,从3开始计数到0。就像最初3出现然后消失,2出现等等。我进行了很多搜索,但找不到任何好的样本。你能帮我看看我该怎么办吗?
使用倒计时器
例如:
import android.os.CountDownTimer;
MyCount timerCount;
public class TestCountdown extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
timerCount = new MyCount(3 * 1000, 1000);
timerCount.start();
}
public class MyCount extends CountDownTimer {
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
//some script here
}
@Override
public void onTick(long millisUntilFinished) {
//some script here
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)