I want to “connect” long press with scroll, so the user doesn’t have to release the screen and start to scroll.
I have gesture detector implemented…
final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
public void onLongPress(MotionEvent e) {
// action 1
}
public boolean onScroll(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
// action 2
}
}
public boolean onTouchEvent(MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
But now between action 1 and action 2, user have to release the screen… How can I connect this actions without releasing the screen??
I don’t think a
GestureDetectorwill do what you want, more likely you’ll have to do it yourself. I don’t know your current setup, below is a class with aOnToucListenertied to aScrollViewwhich will take in consideration both events: