Difference between Click and Touch Listeners in Android

后端 未结 4 543
暗喜
暗喜 2021-02-07 03:11

I have a bit of doubt. I am using an image button (e.g. Play icon in media player). I want to know which action Listener I am supposed to use, onClickListener or onTouchListener

4条回答
  •  后悔当初
    2021-02-07 04:01

    The onClickListener is a number of events that are triggered using either the keyboard or the touchscreen. They are performed on a specific view, and the entire view receives the event. In contrast, the onTouchListener is used only for touchscreen events, and they cannot be triggered through the keyboard or any other inputs. They typically also receive the corresponding touch information like the x, y corrdinates, etc.

    I think the onClickListener would be appropriate for your application, if you are not using more complex inputs, like gestures, etc.

提交回复
热议问题