Onfling would get executed when a user makes a "fling" motion, and said motion have a velocity with it to determine the type of fling it was. However,
If a user simply touches the device and moves slowly across the screen, which would not being considered a fling, but a swipe.
It comes down to what type of motion you expect the users to perform. The ideal case would is to implement the Onfling function to capture that
Motion, and also implement Ondrag and ondragfinished to capture the more subtle motions this should still be considered a Swipe.
Public classMyActivityextendsActivity {Private voidonCreate () {FinalGesturedetector GDT =NewGesturedetector (NewGesturelistener ()); FinalImageView ImageView =(ImageView) Findviewbyid (R.id.image_view); Imageview.setontouchlistener (NewOntouchlistener () {@Override Public BooleanOnTouch (FinalView View,Finalmotionevent Event) {gdt.ontouchevent (event); return true; } }); } Private Static Final intSwipe_min_distance = 120; Private Static Final intswipe_threshold_velocity = 200; Private classGesturelistenerextendsSimpleongesturelistener {@Override Public BooleanOnfling (motionevent E1, motionevent E2,floatVelocityx,floatvelocityy) { if(E1.getx ()-E2.getx () > Swipe_min_distance && math.abs (Velocityx) >swipe_threshold_velocity) { return false;// Right-left}Else if(E2.getx ()-E1.getx () > Swipe_min_distance && math.abs (Velocityx) >swipe_threshold_velocity) { return false;// left to right } if(E1.gety ()-e2.gety () > Swipe_min_distance && math.abs (velocityy) >swipe_threshold_velocity) { return false;//Bottom to top}Else if(E2.gety ()-e1.gety () > Swipe_min_distance && math.abs (velocityy) >swipe_threshold_velocity) { return false;//Top to bottom } return false; } }}