android developed using setOnClickListener click event to achieve the double-click event solutions

android is not provided to us directly double-click the event method, of course, can be used setOnTouchListener used here to provide a compact implementation method 
using kotlin codes are as follows:
private was last click time = 0L
textView.setOnClickListener {
val clickTime = System.currentTimeMillis()
lastClickTime = if (lastClickTime > 0L && clickTime - lastClickTime < 500) {
LogUtils.e("double click:${clickTime - lastClickTime}")
0L
} else {
clickTime
}
}

 

Guess you like

Origin www.cnblogs.com/yongfengnice/p/12654808.html