我正在尝试通过实现 GestureDetector.OnGestureListener
来使用onFling我有此代码:
GestureDetector gDetector;
gDetector = new GestureDetector( context, this );
@Override
public boolean onDown(MotionEvent arg0) {
return true;
}
@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float xVelocity, float yVelocity) {
if (start.getRawY() < finish.getRawY()) {
Log.d( TAG, "Swiped down!" );
} else {
Log.d( TAG, "Swiped up!" );
}
return true;
}
@Override
public void onLongPress(MotionEvent arg0) {
}
@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
return false;
}
@Override
public void onShowPress(MotionEvent arg0) {
}
@Override
public boolean onSingleTapUp(MotionEvent arg0) {
Log.d( TAG, "Just tapped at " + arg0.getRawX() + "," + arg0.getRawY() + "!" );
return false;
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return gDetector.onTouchEvent(motionEvent);
不幸的是,从未击中过onFling,但是却击中了onTouchEvent。
我的问题很简单:为什么?
谢谢您的帮助!