Closed GoogleCodeExporter closed 9 years ago
Original comment by allev...@google.com
on 23 Apr 2014 at 4:14
I worked out a solution for this issue, using Gesture detector. It's simple to
implement this.
Check below -
private GestureDetector createGestureDetector(Context context) {
GestureDetector gestureDetector = new GestureDetector(context);
//Create a base listener for generic gestures
gestureDetector.setBaseListener( new GestureDetector.BaseListener() {
@Override
public boolean onGesture(Gesture gesture) {
if (gesture == Gesture.SWIPE_RIGHT) {
// do something on right (forward) swipe
LISTVIEW.setSelection(LISTVIEW.getSelectedItemPosition()+1);
return true;
} else if (gesture == Gesture.SWIPE_LEFT) {
// do something on left (backwards) swipe
LISTVIEW.setSelection(LISTVIEW.getSelectedItemPosition()-1);
return true;
}
return false;
}
});
gestureDetector.setFingerListener(new GestureDetector.FingerListener() {
@Override
public void onFingerCountChanged(int previousCount, int currentCount) {
// do something on finger count changes
}
});
gestureDetector.setScrollListener(new GestureDetector.ScrollListener() {
@Override
public boolean onScroll(float displacement, float delta, float velocity) {
// do something on scrolling
}
});
return gestureDetector;
}
/*
* Send generic motion events to the gesture detector
*/
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (mGestureDetector != null) {
return mGestureDetector.onMotionEvent(event);
}
return false;
}
Original comment by birendra...@gmail.com
on 24 Apr 2014 at 7:01
Original issue reported on code.google.com by
Mark.Bi...@gmail.com
on 19 Apr 2014 at 3:54