GestureDetector.SimpleOnGestureListener. How to define an ACTION_UP event?

Using this

mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } 

Defines only one tap event, i.e. quick shutdown and shutdown. If I held on and then let go, onSingleTapUp not called.

I am looking for a motion event that ACTION_UP after hold.

I looked at onShowPress , which is called when the user performs a top-down action, but then I was not sure how to determine ACTION_UP while in onShowPress .

Please note that this is for a recycler view for clicks. At the moment, I can select one element that works, but if I hold it and then release it, it is not called.

+7
android android-event android-recyclerview android-gesture
source share
2 answers

In the onSingleTapUp method onSingleTapUp you can try the following:

 @Override public boolean onSingleTapUp(MotionEvent e) { if(e.getAction() == MotionEvent.ACTION_UP){ // Do what you want return true; } return false; } 
+1
source share

You can subclass your view and override onTouchEvent . This will allow you to observe the various actions before the gesture detector processes them.

 @Override public boolean onTouchEvent(MotionEvent e) { int action = e.getActionMasked(); if (action == MotionEvent.ACTION_UP) { // do something here } return mGestureDetector.onTouchEvent(e); } 
0
source share

All Articles