Kotlin Runnable定时器写法

第一种写法

var mStartVideoHandler: Handler = Handler()

var mStartVideoRunnable: Runnable =object: Runnable {

override funrun() {

mStartVideoHandler.postDelayed(this,10000)

}

}

第二种:

private lateinit varrunnalble:Runnable

init{

runnalble=Runnable{

mStartVideoHandler.postDelayed(runnalble,10000)

}

}

第三种 自己赋值给自己

   private fun mStartVideoRunnable() = mStartVideoRunnable

你可能感兴趣的:(Kotlin Runnable定时器写法)