Most visited

Recently visited

Added in API level 1

GestureDetector.SimpleOnGestureListener

public static class GestureDetector.SimpleOnGestureListener
extends Object implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, GestureDetector.OnContextClickListener

java.lang.Object
   ↳ android.view.GestureDetector.SimpleOnGestureListener


一个便利的课程,当你只想听所有手势的一个子集时可以扩展。 这实现所有方法在GestureDetector.OnGestureListenerGestureDetector.OnDoubleTapListener ,并GestureDetector.OnContextClickListener但什么都不做,返回false所有适用的方法。

Summary

Public constructors

GestureDetector.SimpleOnGestureListener()

Public methods

boolean onContextClick(MotionEvent e)

发生上下文点击时通知。

boolean onDoubleTap(MotionEvent e)

发生双击时通知。

boolean onDoubleTapEvent(MotionEvent e)

当发生双击手势中的事件(包括向下,向上和向上事件)时通知。

boolean onDown(MotionEvent e)

当触发触发它的向下触发 MotionEvent触发通知。

boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)

当它发生在 MotionEvent和匹配 MotionEvent的初始状态时,通知其发生了 MotionEvent

void onLongPress(MotionEvent e)

当长按发生时,通知 MotionEvent触发它。

boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)

当滚动发生时,通知通知 MotionEvent和当前移动 MotionEvent

void onShowPress(MotionEvent e)

用户已经执行了一次下跌 MotionEvent并且没有执行任何操作。

boolean onSingleTapConfirmed(MotionEvent e)

单击时发出通知。

boolean onSingleTapUp(MotionEvent e)

当触发它的 MotionEvent触发时发出通知。

Inherited methods

From class java.lang.Object
From interface android.view.GestureDetector.OnGestureListener
From interface android.view.GestureDetector.OnDoubleTapListener
From interface android.view.GestureDetector.OnContextClickListener

Public constructors

GestureDetector.SimpleOnGestureListener

Added in API level 1
GestureDetector.SimpleOnGestureListener ()

Public methods

onContextClick

Added in API level 23
boolean onContextClick (MotionEvent e)

发生上下文点击时通知。

Parameters
e MotionEvent: The motion event that occurred during the context click.
Returns
boolean true if the event is consumed, else false

onDoubleTap

Added in API level 3
boolean onDoubleTap (MotionEvent e)

发生双击时通知。

Parameters
e MotionEvent: The down motion event of the first tap of the double-tap.
Returns
boolean true if the event is consumed, else false

onDoubleTapEvent

Added in API level 3
boolean onDoubleTapEvent (MotionEvent e)

当发生双击手势中的事件(包括向下,向上和向上事件)时通知。

Parameters
e MotionEvent: The motion event that occurred during the double-tap gesture.
Returns
boolean true if the event is consumed, else false

onDown

Added in API level 1
boolean onDown (MotionEvent e)

当触发触发它的向下触发MotionEvent时发出通知。 这将在每次下降事件时立即触发。 所有其他事件应该在此之前。

Parameters
e MotionEvent: The down motion event.
Returns
boolean

onFling

Added in API level 1
boolean onFling (MotionEvent e1, 
                MotionEvent e2, 
                float velocityX, 
                float velocityY)

当它发生在初始状态MotionEvent和匹配MotionEvent时,通知它发生了。 计算出的速度沿x和y轴以像素/秒为单位提供。

Parameters
e1 MotionEvent: The first down motion event that started the fling.
e2 MotionEvent: The move motion event that triggered the current onFling.
velocityX float: The velocity of this fling measured in pixels per second along the x axis.
velocityY float: The velocity of this fling measured in pixels per second along the y axis.
Returns
boolean true if the event is consumed, else false

onLongPress

Added in API level 1
void onLongPress (MotionEvent e)

当长按发生时,通知 MotionEvent触发它。

Parameters
e MotionEvent: The initial on down motion event that started the longpress.

onScroll

Added in API level 1
boolean onScroll (MotionEvent e1, 
                MotionEvent e2, 
                float distanceX, 
                float distanceY)

当滚动发生时,通知当初始向下MotionEvent和当前移动MotionEvent x和y的距离也是为了方便而提供的。

Parameters
e1 MotionEvent: The first down motion event that started the scrolling.
e2 MotionEvent: The move motion event that triggered the current onScroll.
distanceX float: The distance along the X axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
distanceY float: The distance along the Y axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
Returns
boolean true if the event is consumed, else false

onShowPress

Added in API level 1
void onShowPress (MotionEvent e)

用户已经执行了一次下跌MotionEvent并且没有执行任何操作。 此事件通常用于向用户提供视觉反馈,让他们知道他们的行为已被识别,即突出显示一个元素。

Parameters
e MotionEvent: The down motion event

onSingleTapConfirmed

Added in API level 3
boolean onSingleTapConfirmed (MotionEvent e)

单击时发出通知。

onSingleTapUp(MotionEvent)不同,只有在检测器确信用户的第一次敲击后没有第二次敲击导致双击手势后才会调用此功能。

Parameters
e MotionEvent: The down motion event of the single-tap.
Returns
boolean true if the event is consumed, else false

onSingleTapUp

Added in API level 1
boolean onSingleTapUp (MotionEvent e)

MotionEvent触发触发时会发出通知。

Parameters
e MotionEvent: The up motion event that completed the first tap
Returns
boolean true if the event is consumed, else false

Hooray!