Android的,是有一个OnRelease的功能呢? [英] Android, is there an OnRelease functions?
问题描述
说我想要一个对话框,以 .show(),当用户触摸某个元素
和 .hide()
一旦他释放了。
Say I want a dialog to .show()
when the user Touches a certain element and .hide()
once he releases it.
我发现如何让 OnTouchListener
。但有任何形式的 OnReleaseListener
?
I found how to make the OnTouchListener
. But is there any sort of OnReleaseListener
?
谢谢!
推荐答案
这就是实际包含在 OnTouchListener
。它给你的回调MotionEvent,
使用 MotionEvent.getAction()
并检查它是否等于 MotionEvent.ACTION_UP
。这意味着发布了手指的用户。
Thats actually included in the OnTouchListener
. It gives you a MotionEvent on the callback,
use MotionEvent.getAction()
and check if it equals MotionEvent.ACTION_UP
. That means the user released the finger.
同样可以检查 ACTION_DOWN
来区分这两个。
Equally you can check for ACTION_DOWN
to differentiate the two.
这篇关于Android的,是有一个OnRelease的功能呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!