GestureDetector gestureDetector = new GestureDetector (new MyGestureDetector());
// *** 觸控事件 ******************
@Override public boolean onTouchEvent(MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } return true; }
// *** 事件 fling event********
private class MyGestureDetector extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 50; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { } // left to right swipe else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { } } catch (Exception e) { // nothing } return false; } }
dendroid, download, 下載, 知識, 正妹, Java, 成人, tutorial, 教學, 學習, 程式碼, 筆記, 18x, app, free, 免費, 簡易, 超人氣, Dendroidz, Destiny, Naruto
Android 手指滑動事件 (fling event)
標籤:
android
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言