Build 1.0_r1(from source)

android.view
Class GestureDetector

java.lang.Object
  extended by android.view.GestureDetector

public class GestureDetector
extends Object

Detects various gestures and events using the supplied MotionEvents. The GestureDetector.OnGestureListener callback will notify users when a particular motion event has occurred. This class should only be used with MotionEvents reported via touch (don't use for trackball events). To use this class:


Nested Class Summary
static interface GestureDetector.OnGestureListener
          The listener that is used to notify when gestures occur.
static class GestureDetector.SimpleOnGestureListener
          A convenience class to extend when you only want to listen for a subset of all the gestures.
 
Constructor Summary
GestureDetector(GestureDetector.OnGestureListener listener)
          Creates a GestureDetector with the supplied listener.
GestureDetector(GestureDetector.OnGestureListener listener, Handler handler)
          Creates a GestureDetector with the supplied listener.
 
Method Summary
 boolean isLongpressEnabled()
           
 boolean onTouchEvent(MotionEvent ev)
          Analyzes the given motion event and if applicable triggers the appropriate callbacks on the GestureDetector.OnGestureListener supplied.
 void setIsLongpressEnabled(boolean isLongpressEnabled)
          Set whether longpress is enabled, if this is enabled when a user presses and holds down you get a longpress event and nothing further.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GestureDetector

public GestureDetector(GestureDetector.OnGestureListener listener,
                       Handler handler)
Creates a GestureDetector with the supplied listener. This variant of the constructor should be used from a non-UI thread (as it allows specifying the Handler).

Parameters:
listener - the listener invoked for all the callbacks, this must not be null.
handler - the handler to use, this must not be null.
Throws:
NullPointerException - if either listener or handler is null.

GestureDetector

public GestureDetector(GestureDetector.OnGestureListener listener)
Creates a GestureDetector with the supplied listener. You may only use this constructor from a UI thread (this is the usual situation).

Parameters:
listener - the listener invoked for all the callbacks, this must not be null.
Throws:
NullPointerException - if listener is null.
See Also:
Handler.Handler()
Method Detail

setIsLongpressEnabled

public void setIsLongpressEnabled(boolean isLongpressEnabled)
Set whether longpress is enabled, if this is enabled when a user presses and holds down you get a longpress event and nothing further. If it's disabled the user can press and hold down and then later moved their finger and you will get scroll events. By default longpress is enabled.

Parameters:
isLongpressEnabled - whether longpress should be enabled.

isLongpressEnabled

public boolean isLongpressEnabled()
Returns:
true if longpress is enabled, else false.

onTouchEvent

public boolean onTouchEvent(MotionEvent ev)
Analyzes the given motion event and if applicable triggers the appropriate callbacks on the GestureDetector.OnGestureListener supplied.

Parameters:
ev - The current motion event.
Returns:
true if the GestureDetector.OnGestureListener consumed the event, else false.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature