2
I have an application running on Android with a Gridview (grid).
On this grid I need to detect various events and so I’m using a gesture detector. Only by clicking on a grid item, sometimes the onFling
instead of onSingleTapUp
.
Is the behavior really like that or am I doing something wrong? If that’s how I can get around the problem?
class DetectorGestosGrelha extends SimpleOnGestureListener
{
/**
* Para passar de uma grelha para outra ao deslizar o dedo
* da direita para a esquerda.
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX,float velocityY)
{
//meu código
return false;
}
/**
* Para ir para outra atividade ao clicar num elemento da grelha.
*/
@Override
public boolean onSingleTapUp(MotionEvent e)
{
//meu código
return true;
}
@Override
public void onLongPress(MotionEvent e)
{
//meu código
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY)
{
//meu código
return true;
}
@Override
public void onShowPress(MotionEvent e)
{
super.onShowPress(e);
}
@Override
public boolean onDown(MotionEvent e)
{
//meu código
return true;
}
}
Cross-posting : Gesturedetector conflit onFling vs onSingleTapUp
– Jorge B.
Are you applying some "filter" to accept "Esture" as "Fling"? That is, you should only accept a "Esture" as "Fling" if it has a certain amplitude and speed.
– ramaral
@I am but it is inside the
onFling
.– Jorge B.
Yes it would be there. Try to increase the values.
– ramaral
@ramaral this is already right, I did not explain well then. It will stop at the
onFling
but does nothing, but then does not pass in theonSingleTapUp
and does not do what I want is to go to another activity.– Jorge B.
The next suggestion would be to return the method
false
, but you already do. I can’t think of anything else.– ramaral
The difficulty is in the problem not always occur, however try to put
return false
in the methodonDown()
.– ramaral
See the class Gestureeventlogger.java of this reply and put your Return equal.
– ramaral
The problem seems to be the sensitivity to touch, if I put the tablet lying down and use a pen own works well, but as it is a software for a restaurant has to be fast and that is why it gives this problem.
– Jorge B.
Let’s go continue this discussion in chat.
– Jorge B.