Android SDK | API level 24 | GestureDetector
来源:互联网 发布:python 函数传递对象 编辑:程序博客网 时间:2024/06/18 06:53
GestureDetector
public class GestureDetector
extends Object
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:
- Create an instance of the
GestureDetector
for yourView
- In the
onTouchEvent(MotionEvent)
method ensure you callonTouchEvent(MotionEvent)
. The methods defined in your callback will be executed when the events occur. - If listening for
onContextClick(MotionEvent)
you must callonGenericMotionEvent(MotionEvent)
inonGenericMotionEvent(MotionEvent)
.
使用提供的MotionEvents检测各种手势和事件。
当某个特定的运动事件发生时,回调函数GestureDetector.OnGestureListener将会通知用户。
这个类只应用于触摸事件,而不应用于追踪事件。为了使用这个类:
1、为你的View创建一个GestureDetector句柄。
2、在onTouchEvent(MotionEvent)方法里面,确保你调用了onTouchEvent(MotionEvent)。回调中定义的方法,将在事件发生时执行。
3、如果监听onContextClick(MotionEvent),你必须在onGenericMotionEvent(MotionEvent)中调用onGenericMotionEvent(MotionEvent)。
Summary
此监听器用来通知context的click事件。interfaceGestureDetector.OnDoubleTapListenerThe listener that is used to notify when a double-tap or a confirmed single-tap occur.
此监听器用来通知双击或者单击确认事件。interfaceGestureDetector.OnGestureListenerThe listener that is used to notify when gestures occur.
此监听器用来监听手势事件。classGestureDetector.SimpleOnGestureListenerA convenience class to extend when you only want to listen for a subset of all the gestures.
当你只想监听所有手势事件的一个部分时,可以继承这个方便的类。
java.lang.Object类中的方法
Public Constructors
GestureDetector
Added in API level 1GestureDetector (GestureDetector.OnGestureListener listener, Handler handler)
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一起创建一个GestureDetector 。这个版本的构造函数应该用于非UI线程上(因为它允许指定Handle)。
GestureDetector
GestureDetector (GestureDetector.OnGestureListener listener)
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一起创建一个GestureDetector。你可以只在UI线程上使用这个构造函数(这是一般情况)。GestureDetector
GestureDetector (Context context, GestureDetector.OnGestureListener listener)
Creates a GestureDetector with the supplied listener. You may only use this constructor from a Looper
thread.
GestureDetector
GestureDetector (Context context, GestureDetector.OnGestureListener listener, Handler handler)
Creates a GestureDetector with the supplied listener that runs deferred events on the thread associated with the supplied Handler
.
GestureDetector
GestureDetector (Context context, GestureDetector.OnGestureListener listener, Handler handler, boolean unused)
Creates a GestureDetector with the supplied listener that runs deferred events on the thread associated with the supplied Handler
.
Public methods
isLongpressEnabled
Added in API level 1boolean isLongpressEnabled ()
Returnsbooleantrue if longpress is enabled,else false. 如果长按是有效的是true,否则为false。
onGenericMotionEvent
boolean onGenericMotionEvent (MotionEvent ev)
Analyzes the given generic motion event and if applicable triggers the appropriate callbacks on the GestureDetector.OnGestureListener
supplied.
如果GestureDetector.OnGestureListener监听到了事件,则是真的,否则为假。
onTouchEvent
boolean onTouchEvent (MotionEvent ev)
Analyzes the given motion event and if applicable triggers the appropriate callbacks on the GestureDetector.OnGestureListener
supplied.
如果GestureDetector.OnGestureListener监听到了事件,则是真的,否则为假。
setContextClickListener
void setContextClickListener (GestureDetector.OnContextClickListener onContextClickListener)
Sets the listener which will be called for context clicks.
设置context clicks的监听器。
setIsLongpressEnabled
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.
设置长按是否可用,如果可用,当用户按下并保持按下下滑的时候,你会接收到一个长按事件,并无其他。如果是不可用的,则用户可以按下和保持按下下滑,然后过了一会移开手指,会得到滑动事件。默认长按是可用的。boolean: 是否长按是可用的。
setOnDoubleTapListener
void setOnDoubleTapListener (GestureDetector.OnDoubleTapListener onDoubleTapListener)
Sets the listener which will be called for double-tap and related gestures.
为双击和相关手势设置监听器。翻译有不足之处,欢迎指正~
- Android SDK | API level 24 | GestureDetector
- android sdk | API level 24 | android
- android sdk | API level 24 | Manifest
- android sdk | API level 24 | Manifest.permission
- android sdk | API level 24 | Manifest.permission_group
- android sdk | API level 24 | R
- android sdk | API level 24 | R.anim
- android sdk | API level 24 | R.animator
- android sdk | API level 24 | R.array
- Android SDK中的API Level 对应关系
- Android SDk 与API Level 对应关系
- Android SDK Version And API Level Chart
- Android SDK和API Level对照表
- Android SDK和API Level对照表
- Android SDK与API Level对应关系
- Android SDK 与 API level 对应表
- Android SDK和API Level对照表
- Android SDK版本号 与 API Level
- 【剑指**】5.替换空格
- GYM 101522B. Bacteria Experiment
- Tablayout+Frament+ViewPager
- C++学习之入门求平均数
- Maven导入建立父子项目时的问题
- Android SDK | API level 24 | GestureDetector
- WebView简单使用
- localhost:8080/项目名称
- node使用
- Java中的缓冲流
- WannaCay病毒肆虐 美国竟说北韩是幕后真凶 着又是意欲何为
- recyclerview条目点击事件
- 订单详情的适配器
- 基于Dragonboard 410c进行开发的远程遥控机器人(三)