如何在onResume()中调用我的CountDownTimer?
private fun countDownTime(timeOut: Long) {
object : CountDownTimer(timeOut, 1000) {
override fun onTick(millisUntilFinished: Long) {
actionWarning.text = "Please wait: " + millisUntilFinished / 1000
}
override fun onFinish() {
}
}.start()
}发布于 2017-05-10 23:40:57
看起来您需要将CountDownTimer提取到一个字段中:
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()
}
}https://stackoverflow.com/questions/43895716
复制相似问题