首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用countDownTimer

调用countDownTimer
EN

Stack Overflow用户
提问于 2017-05-10 22:41:06
回答 1查看 992关注 0票数 0

如何在onResume()中调用我的CountDownTimer?

代码语言:javascript
复制
private fun countDownTime(timeOut: Long) {
    object : CountDownTimer(timeOut, 1000) {
        override fun onTick(millisUntilFinished: Long) {
            actionWarning.text = "Please wait: " + millisUntilFinished / 1000
        }
        override fun onFinish() {
        }
    }.start()
}
EN

回答 1

Stack Overflow用户

发布于 2017-05-10 23:40:57

看起来您需要将CountDownTimer提取到一个字段中:

代码语言:javascript
复制
class YourClass {

    val timer = object : CountDownTimer(timeOut, 1000) {
            override fun onTick(millisUntilFinished: Long) {
                actionWarning.text = "Please wait: " + millisUntilFinished / 1000
            }
            override fun onFinish() {
            }
        }

    private fun countDownTime(timeOut: Long) {
      timer.start()
    }

    fun onResume() {
      timer.whatever()
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43895716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档