我需要使用 SimpleOnGestureListener 的 onFling 方法。
private class GestureListener extends SimpleOnGestureListener {
public GestureListener() {
super();
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
//Do something...
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
//Do something...
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
//Do something...
return super.onSingleTapConfirmed(e);
}
@Override
public void onLongPress(MotionEvent e) {
//Do something...
}
@Override
public boolean onDoubleTap(MotionEvent e) {
//Do something...
return super.onDoubleTap(e);
}
}
OnScroll 方法总是被调用!
OnFling 并不总是被调用。我必须实施什么吗?