Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect a motion event when an onClick listener is there?

I have a ListView with onItemClick() method . Now I want to detect a touch motion in the screen . Implementing onTouchEvent() does not work in this case since I have written already a click listener . So help me how to do it. I need both the on click listener and onTouchEvent().

like image 908
arul Avatar asked Oct 28 '25 14:10

arul


1 Answers

You need to implement the OnTouchListener(View v, MotionEvent event) to check event.getX() and event.getY() when event.ACTION_DOWN and event.ACTION_UP and compare them to know the motion direction.

Note: you must return true to be able to receive the event.ACTION_UP event.

like image 66
Mohamed_AbdAllah Avatar answered Oct 31 '25 05:10

Mohamed_AbdAllah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!