Android倒数计时器解释通缉

Android倒数计时器解释通缉,第1张

概述在 android参考资料中我发现了一个关于countdowntimers的页面: CountDownTimers 它里面有这段代码: new CountDownTimer(30000, 1000) { public void onTick(long millisUntilFinished) { mTextField.setText("seconds remainin 在 android参考资料中我发现了一个关于countdowntimers的页面: CountDownTimers

它里面有这段代码:

new CountDownTimer(30000,1000) {     public voID onTick(long millisUntilFinished) {         mTextFIEld.setText("seconds remaining: " + millisUntilFinished / 1000);     }     public voID onFinish() {         mTextFIEld.setText("done!");     }  }.start();

我想知道它是什么,以及它是一个对象或类,以及如何将它用作不同类对象的计时器.有人可以解释我将如何把它放入我的androID项目并使用它.谢谢.

解决方法 公共建筑师:

CountDownTimer(long millisInFuture,long countDownInterval)

公共方法:

final voID  cancel()    Cancel the countdown.abstract voID   onFinish()    Callback fired when the time is up.abstract voID   onTick(long millisUntilFinished)    Callback fired on regular interval.synchronized final CountDownTimer   start()    Start the countdown.

公共建筑师:

public CountDownTimer (long millisInFuture,long countDownInterval)Parameters1. millisInFuture   The number of millis in the future from the call to start() until the countdown is done and onFinish() is called.2. countDownInterval    The interval along the way to receive onTick(long) callbacks.

公共方法:

public final voID cancel ()    Cancel the countdown.public abstract voID onFinish ()    Callback fired when the time is up.public abstract voID onTick (long millisUntilFinished)    Callback fired on regular interval.        Parameters: millisUntilFinished     The amount of time until finished.public final synchronized CountDownTimer start ()    Start the countdown.

教程链接:

link 1

link 2

link 3

编辑:

new CountDownTimer(30000 /*For how long should timer run*/,1000 /*time interval after which `onTick()` should be called*/) { public voID onTick(long millisUntilFinished) {     Log.i("Countdown Timer: ","seconds remaining: " + millisUntilFinished / 1000); } public voID onFinish() {     //Done timer time out.     myTextVIEw.setText("Time Out.!"); }}.start();
总结

以上是内存溢出为你收集整理的Android倒数计时器解释通缉全部内容,希望文章能够帮你解决Android倒数计时器解释通缉所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1130072.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存