I want to detect fling motion in a block of the screen. I am using the following code for that.
public class MyinfoActivity extends Activity implements OnGestureListener {
@Override
public void onCreate(Bundle savedInstanceState) {
..........
..........
gestureScanner = new GestureDetector(this);
resBlock = (TableRow) findViewById(R.id.ResBlock);
gestureScanner = new GestureDetector(this);
}
@Override
public boolean onTouchEvent(MotionEvent me){
Log.d(null,"Touch");
if (gestureScanner.onTouchEvent(me))
return gestureScanner.onTouchEvent(me);
else
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
Log.d(null,"Fling");
............
............
}
@Override
public boolean onDown(MotionEvent arg0) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
}
It is detecting the TouchEvent, but it is not detecting any fling motion. What is the problem in my code?
true
in theonDown(MotionEvent)
method! – Gatling