1

I am trying to understand what clickable in Android means. I have a simple Button subclass which overrides onTouchEvent() and also implements OnTouchListener.onTouch() (returns false to let the event bubble up to the view) and I noticed that the callbacks are called with MotionEvent.ACTION_DOWN (listener first, the view method later), and nothing more. I thought clickable = false disables touch events completely, but apparently not. What does it really do? How can I make sure the view doesn't get any touch events at all (setEnabled(false) seems not to work at all, events for ACTION_DOWN, _MOVE and _UP are fired unhindered). Why are some touch events handled and other are not for clickable = false? I find it pretty surprising behavior and inconsistent - I would expect MotionEvent.ACTION_UP to be fired as well, but maybe click listeners should not be called. Any guidance?

Update With setEnabled(false) only the View.onTouchEvent method is called, the listener is ignored. Even stranger...

4

1 回答 1

0

据我了解,setClickable 用于在单击时调用 onClickListener,而 ACTION_DOWN、ACTION_MOVE、ACTION_UP 等操作用于处理 OnTouchListener 中视图上的手指事件。

于 2013-10-22T19:56:39.757 回答