java.lang.Object | |
↳ | android.view.GestureDetector |
Detects various gestures and events using the supplied MotionEvent
s.
The GestureDetector.OnGestureListener
callback will notify users when a particular
motion event has occurred. This class should only be used with MotionEvent
s
reported via touch (don't use for trackball events).
To use this class:
GestureDetector
for your View
onTouchEvent(MotionEvent)
method ensure you call
onTouchEvent(MotionEvent)
. The methods defined in your callback
will be executed when the events occur.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GestureDetector.OnDoubleTapListener | The listener that is used to notify when a double-tap or a confirmed single-tap occur. | ||||||||||
GestureDetector.OnGestureListener | The listener that is used to notify when gestures occur. | ||||||||||
GestureDetector.SimpleOnGestureListener | A convenience class to extend when you only want to listen for a subset of all the gestures. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This constructor was deprecated
in API level 3.
Use
GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler) instead.
| |||||||||||
This constructor was deprecated
in API level 3.
Use
GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener) instead.
| |||||||||||
Creates a GestureDetector with the supplied listener.
| |||||||||||
Creates a GestureDetector with the supplied listener that runs deferred events on the
thread associated with the supplied
Handler . | |||||||||||
Creates a GestureDetector with the supplied listener that runs deferred events on the
thread associated with the supplied
Handler . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Analyzes the given motion event and if applicable triggers the
appropriate callbacks on the
GestureDetector.OnGestureListener supplied. | |||||||||||
Set whether longpress is enabled, if this is enabled when a user
presses and holds down you get a longpress event and nothing further.
| |||||||||||
Sets the listener which will be called for double-tap and related
gestures.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This constructor was deprecated
in API level 3.
Use GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener, android.os.Handler)
instead.
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).
listener | the listener invoked for all the callbacks, this must not be null. |
---|---|
handler | the handler to use |
NullPointerException | if either listener or
handler is null. |
---|
This constructor was deprecated
in API level 3.
Use GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener)
instead.
Creates a GestureDetector with the supplied listener. You may only use this constructor from a UI thread (this is the usual situation).
listener | the listener invoked for all the callbacks, this must not be null. |
---|
NullPointerException | if listener is null. |
---|
Creates a GestureDetector with the supplied listener.
You may only use this constructor from a Looper
thread.
context | the application's context |
---|---|
listener | the listener invoked for all the callbacks, this must not be null. |
NullPointerException | if listener is null.
|
---|
Creates a GestureDetector with the supplied listener that runs deferred events on the
thread associated with the supplied Handler
.
context | the application's context |
---|---|
listener | the listener invoked for all the callbacks, this must not be null. |
handler | the handler to use for running deferred listener events. |
NullPointerException | if listener is null.
|
---|
Creates a GestureDetector with the supplied listener that runs deferred events on the
thread associated with the supplied Handler
.
context | the application's context |
---|---|
listener | the listener invoked for all the callbacks, this must not be null. |
handler | the handler to use for running deferred listener events. |
unused | currently not used. |
NullPointerException | if listener is null.
|
---|
Analyzes the given motion event and if applicable triggers the
appropriate callbacks on the GestureDetector.OnGestureListener
supplied.
ev | The current motion event. |
---|
GestureDetector.OnGestureListener
consumed the event,
else false.
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.
isLongpressEnabled | whether longpress should be enabled. |
---|
Sets the listener which will be called for double-tap and related gestures.
onDoubleTapListener | the listener invoked for all the callbacks, or null to stop listening for double-tap gestures. |
---|