belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
GestureDetectorCompat
public
final
class
GestureDetectorCompat
extends Object
java.lang.Object | |
↳ | android.support.v4.view.GestureDetectorCompat |
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).
This compatibility implementation of the framework's GestureDetector guarantees the newer focal point scrolling behavior from Jellybean MR1 on all platform versions.
To use this class:- Create an instance of the
GestureDetectorCompat
for yourView
- In the
onTouchEvent(MotionEvent)
method ensure you callonTouchEvent(MotionEvent)
. The methods defined in your callback will be executed when the events occur.
Summary
Public constructors | |
---|---|
GestureDetectorCompat(Context context, GestureDetector.OnGestureListener listener)
Creates a GestureDetectorCompat with the supplied listener. |
|
GestureDetectorCompat(Context context, GestureDetector.OnGestureListener listener, Handler handler)
Creates a GestureDetectorCompat with the supplied listener. |
Public methods | |
---|---|
boolean
|
isLongpressEnabled()
|
boolean
|
onTouchEvent(MotionEvent event)
Analyzes the given motion event and if applicable triggers the
appropriate callbacks on the |
void
|
setIsLongpressEnabled(boolean enabled)
Set whether longpress is enabled, if this is enabled when a user presses and holds down you get a longpress event and nothing further. |
void
|
setOnDoubleTapListener(GestureDetector.OnDoubleTapListener listener)
Sets the listener which will be called for double-tap and related gestures. |
Inherited methods | |
---|---|
![]()
java.lang.Object
|
Public constructors
GestureDetectorCompat
GestureDetectorCompat (Context context, GestureDetector.OnGestureListener listener)
Creates a GestureDetectorCompat with the supplied listener. As usual, you may only use this constructor from a UI thread.
Parameters | |
---|---|
context |
Context : the application's context |
listener |