Added in API level XE12
A gesture detector optimized to recognize touch gestures for the touchpad.
There are discrete gesture listeners (e.g., GestureDetector.BaseListener
, GestureDetector.FingerListener
) and continuous gesture listeners, (e.g., GestureDetector.ScrollListener
, GestureDetector.OneFingerScrollListener
, GestureDetector.TwoFingerScrollListener
).
For more information, see the Touch gestures developer guide.
GestureDetector
.onGenericMotionEvent(MotionEvent)
or dispatchGenericFocusedEvent(MotionEvent)
and pass the MotionEvent
to the gesture detector’s onMotionEvent(MotionEvent)
method to process the event.Note: When implementing the
onXXX
methods for listeners, set the return value totrue
only if you do not want to dispatch theMotionEvent
to any other listening entities in the input dispatch pipeline.
Nested Classes | ||
---|---|---|
interface | GestureDetector.BaseListener | Receives detection results. |
interface | GestureDetector.FingerListener | This listener reports when the detected finger count changes on the touchpad. |
interface | GestureDetector.OneFingerScrollListener | This listener receives continuous one finger horizontal scrolling events. |
interface | GestureDetector.ScrollListener | This listener receives continuous horizontal scrolling events independent of the finger count. |
interface | GestureDetector.TwoFingerScrollListener | This listener receives continuous two finger horizontal scrolling events. |
Public Constructors | |
---|---|
GestureDetector(Context context) |
Public Methods | |
---|---|
static boolean | isForward(Gesture gesture) |
static boolean | isForward(float deltaX) |
boolean | onMotionEvent(MotionEvent event) |
GestureDetector | setAlwaysConsumeEvents(boolean enabled) |
GestureDetector | setBaseListener(GestureDetector.BaseListener listener) |
GestureDetector | setFingerListener(GestureDetector.FingerListener listener) |
GestureDetector | setOneFingerScrollListener(GestureDetector.OneFingerScrollListener listener) |
GestureDetector | setScrollListener(GestureDetector.ScrollListener listener) |
GestureDetector | setTwoFingerScrollListener(GestureDetector.TwoFingerScrollListener listener) |
Inherited Methods | |
---|---|
From class java.lang.Object | |
Object | clone() |
boolean | equals(Object arg0) |
void | finalize() |
final Class<?> | getClass() |
int | hashCode() |
final void | notify() |
final void | notifyAll() |
String | toString() |
final void | wait() |
final void | wait(long arg0, int arg1) |
final void | wait(long arg0) |
Added in API level XE12
Added in API level XE16
Returns true
if the given gesture corresponds to forward motion on the touchpad.
This method only makes sense for lateral swipes and throws an exception if called on other gestures.
Added in API level XE16
Returns true
if the given displacement corresponds to forward motion on the touchpad.
Added in API level XE12
Processes a motion event, returning true
if events should always be consumed or if a gesture was detected.
Added in API level XE12
Sets if the gesture detector should consume events passed to onMotionEvent(MotionEvent)
, regardless of whether they were actually handled.
Added in API level XE12
Sets the basic gesture listener.
Added in API level XE12
Sets the finger listener.
Added in API level XE21
Sets the listener that detects horizontal and one finger scrolling.
Added in API level XE12
Sets the listener that detects horizontal scrolling independent of the finger count.
Added in API level XE12
Sets the listener that detects horizontal and two finger scrolling.
Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 4.0 Attribution License.