【发布时间】:2018-04-10 13:31:05
【问题描述】:
如何使用 kotlin 向左或向右滑动来捕获事件?
我已经实现了 OnTouchListener 来尝试捕获某些内容,但什么也没发生。
class MyClass : Fragment(), View.OnTouchListener {
lateinit var mRootView: View
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
mRootView = inflater.inflate(myLayout, container, false)
mRootView.setOnTouchListener(this)
return mRootView
}
override fun onTouch(view: View?, event: MotionEvent?): Boolean {
println("test")
println(event?.actionMasked.toString())
return true
}
}
【问题讨论】:
标签: android kotlin kotlin-android-extensions kotlin-extension