I have an Android app with a GridView.
In that grid I need to detect many events and I have to use a GestureDetector, but sometimes when I click on a grid item is triggered the event onFling
instead of onSingleTapUp
.
What I'm doing wrong?
class GestureDetectorGrid extends SimpleOnGestureListener
{
/**
* Sliding from right to the left to move to another grid
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX,float velocityY)
{
//my code
return false;
}
/**
* Go to another Activity by clicking on a element from the grid.
*/
@Override
public boolean onSingleTapUp(MotionEvent e)
{
//my code
return true;
}
@Override
public void onLongPress(MotionEvent e)
{
//my code
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY)
{
//my code
return true;
}
@Override
public void onShowPress(MotionEvent e)
{
super.onShowPress(e);
}
@Override
public boolean onDown(MotionEvent e)
{
//my code
return true;
}
}
My question is different from duplicate because I want to know why the Android GestureDetector assumes onFling
instead onSingleTapUp
. Or if I'm doing something wrong.