我是kotlin android开发公司的新成员。所以我想知道怎么用
inline fun Timer.scheduleAtFixedRate(
delay: Long,
period: Long,
crossinline action: TimerTask.() -> Unit
): TimerTask意思是任何例子..。
提前谢谢。
发布于 2019-09-17 06:43:05
尝尝这个
Timer().schedule(object : TimerTask() {
override fun run() {
Log.e("NIlu_TAG","Hello World")
}
}, 3000)或者这个
Timer().schedule(timerTask {
Log.e("NIlu_TAG","Hello World")
}, 3000)或者这个
Timer().scheduleAtFixedRate(object : TimerTask() {
override fun run() {
Log.e("NIlu_TAG","Hello World")
}
},2000,2)简短回答
Timer().scheduleAtFixedRate(timerTask {
Log.e("NIlu_TAG","Hello World")
},2000,2)发布于 2020-04-24 22:01:00
您也可以这样做:
val fixedRateTimer = fixedRateTimer(name = "hello-timer",
initialDelay = 1000, period = 1000,daemon = true) {
println("Hello")
}https://stackoverflow.com/questions/57968658
复制相似问题