Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnUp event on GestureDetector

My question is simple, where's the onUp event when implementing a GestureListener?

I has a lot of events on the gesturedetector, and cannot just consume the onUp event of the listener, cause one of events are the onSingleTapConfirmed that needs it.

like image 904
Marcos Vasconcelos Avatar asked Apr 19 '11 21:04

Marcos Vasconcelos


People also ask

What is a Gesture in Android?

Advertisements. Android provides special types of touch screen events such as pinch , double tap, scrolls , long presses and flinch. These are all known as gestures. Android provides GestureDetector class to receive motion events and tell us that these events correspond to gestures or not.

How to detect gestures in Android?

Detect gestures. Android provides the GestureDetector class for detecting common gestures. Some of the gestures it supports include onDown() , onLongPress() , onFling() , and so on. You can use GestureDetector in conjunction with the onTouchEvent() method described above.

What is onSingleTapUp?

public boolean onSingleTapUp (MotionEvent e) Notified when a tap occurs with the up MotionEvent that triggered it. Parameters. e. MotionEvent : This value cannot be null .


1 Answers

Try using onFling(). Seems like a weird name but for me, it works as the onUp() method would logically work. Or try this method...

@Override public boolean onTouchEvent(MotionEvent me) {    Log.v("ADAM", "ontouch: " + me.getAction());    if(me.getAction() == 0){     Log.v("ADAM", "Down");   }   else if (me.getAction() == 1) {     Log.v("ADAM", "Up");   }   else if (me.getAction() == 2) {     Log.v("ADAM", "Scroll");   }   boolean detectedUp = event.getAction() == MotionEvent.ACTION_UP;   if (!mGestureDetector.onTouchEvent(event) && detectedUp) {     return onUp(event);   }   return true; } 
like image 137
adamwong246 Avatar answered Oct 03 '22 10:10

adamwong246