public interface OnGestureListener {
/**
* Notified when a tap occurs with the down {@link MotionEvent}
* that triggered it. This will be triggered immediately for
* every down event. All other events should be preceded by this.
*
* @param e The down motion event.
*/
boolean onDown(MotionEvent e);
/**
* The user has performed a down {@link MotionEvent} and not performed
* a move or up yet. This event is commonly used to provide visual
* feedback to the user to let them know that their action has been
* recognized i.e. highlight an element.
*
* @param e The down motion event
*/
void onShowPress(MotionEvent e);
/**
* Notified when a tap occurs with the up {@link MotionEvent}
* that triggered it.
*
* @param e The up motion event that completed the first tap
* @return true if the event is consumed, else false
*/
boolean onSingleTapUp(MotionEvent e);
/**
* Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
* current move {@link MotionEvent}. The distance in x and y is also supplied for
* convenience.
*
* @param e1 The first down motion event that started the scrolling.
* @param e2 The move motion event that triggered the current onScroll.
* @param distanceX The distance along the X axis that has been scrolled since the last
* call to onScroll. This is NOT the distance between {@code e1}
* and {@code e2}.
* @param distanceY The distance along the Y axis that has been scrolled since the last
* call to onScroll. This is NOT the distance between {@code e1}
* and {@code e2}.
* @return true if the event is consumed, else false
*/
boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
/**
* Notified when a long press occurs with the initial on down {@link MotionEvent}
* that trigged it.
*
* @param e The initial on down motion event that started the longpress.
*/
void onLongPress(MotionEvent e);
/**
* Notified of a fling event when it occurs with the initial on down {@link MotionEvent}
* and the matching up {@link MotionEvent}. The calculated velocity is supplied along
* the x and y axis in pixels per second.
*
* @param e1 The first down motion event that started the fling.
* @param e2 The move motion event that triggered the current onFling.
* @param velocityX The velocity of this fling measured in pixels per second
* along the x axis.
* @param velocityY The velocity of this fling measured in pixels per second
* along the y axis.
* @return true if the event is consumed, else false
*/
boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
}
其中,
onSingleTapUp
是 短按 up的时候触发,如果是长按,活着滑动,只要时间比较常,就不会触发,所以在这里充当onClick的作用,可以区分ViewFlipper 的onFling和click,所以ViewFlipper就不用onclick了
分享到:
相关推荐
【Android】滑动屏幕效果GestureDetector、OnGestureListener、ViewFlipper
ViewFlipper+OnGestureListener+动画.实现了手势监听。
Android系统自带有一个多页面管理的控件:ViewFlipper. 它可以简单实现子页面的切换,,, 它只需使用addView方法添加几个View,每个View对应的是一个页面,即可完成对于多页面的管理,,, 在android上实现手势...
利用viwflipper来将多个activity封装在一个view中,通过实现OnGestureListener接口的onTouchEvent()方法和onFling() 方法,即可通过手持滑动切换activity。
使用ViewFlipper的手势功能完成的图像之间的切换、 package com.action; import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; import...
本文实例讲述了Android ViewFlipper用法。分享给大家供大家参考,具体如下: 这里实现的效果是当手动滑动手机屏幕时会一个一个地显示图片,一次显示一张图片 package com.my.viewflippertest; import android.app....
一般实现这个特效会用到一个控件:ViewFlipper <1>View切换的控件—ViewFlipper 这个控件是什么呢?请注意观看博文Android学习笔记之ViewFilpper 。 除了这个ViewFlipper,我们还需要了解一下ViewAnimator。它...
一般实现这个特效会用到一个控件:ViewFlipper <1>View切换的控件—ViewFlipper 这个控件是什么呢?请注意观看博文Android学习笔记之ViewFilpper 。 除了这个ViewFlipper,我们还需要了解一下ViewAnimator。它...
GestureDetector的实现 (GestureDetector.OnDoubleTapListener GestureDetector.OnGestureListener) 对应资源
用到了OnGestureListener,OnTouchListener接口。 4、Android 程序的安装、卸载和更新 通过Intent机制,调出系统安装应用/卸载应用,直接调用安装接口, 5、Android有未接来电后处理(判断未接来电) 继承...