private final GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener(){ @Override public boolean onSingleTapConfirmed(MotionEvent e) { MyToast.makeToast(GestureDetectorActivity.this, "single click!"); return super.onSingleTapConfirmed(e); } @Override public boolean onDoubleTap(MotionEvent e) { MyToast.makeToast(GestureDetectorActivity.this, "double click down!"); return super.onDoubleTap(e); } @Override public boolean onDoubleTapEvent(MotionEvent e) { switch (e.getActionMasked()){ case MotionEvent.ACTION_UP: MyToast.makeToast(GestureDetectorActivity.this, "double click up!"); break; } return super.onDoubleTapEvent(e); } @Override public boolean onDown(MotionEvent e) { MyToast.makeToast(GestureDetectorActivity.this, "onDown"); return super.onDown(e); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { mSpeedX = velocityX; mSpeedY = velocityY; handler.postDelayed(runnable, 30); return super.onFling(e1, e2, velocityX, velocityY); } @Override public void onShowPress(MotionEvent e) { MyToast.makeToast(GestureDetectorActivity.this, "onShowPress");// >150ms 時調用 super.onShowPress(e); } @Override public boolean onSingleTapUp(MotionEvent e) {// 雙擊第一次擡起觸發,第二次不觸發 Log.d("onSingleTapUp", "onSingleTapUp");// >150ms 時調用 return super.onSingleTapUp(e); } @Override public void onLongPress(MotionEvent e) { MyToast.makeToast(GestureDetectorActivity.this, "onLongPress"); // 後續工做 super.onLongPress(e); } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { MyToast.makeToast(GestureDetectorActivity.this, "onScroll X = " + distanceX + " Y = " + distanceY); return super.onScroll(e1, e2, distanceX, distanceY); } };