I’m desperately trying to solve this problem:
Only a ACTION_DOWN event triggers my method. The whole day, it worked fine, but now it doesn’t work anymore but i didn’t change anything.
public boolean onTouch(View v, MotionEvent event) {
boolean isReleased = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL;
boolean isPressed = event.getAction() == MotionEvent.ACTION_DOWN;
boolean isMoved = event.getAction() == MotionEvent.ACTION_MOVE;
if(isPressed){
if(Gesture_Done){
reset_It();
}
xPressed = event.getX();
yPressed = event.getY();
action_timelist.add(System.currentTimeMillis());
if(action_timelist.size()>1){
evaluate_actionlist(true);
}
}
else if(isReleased){
if(!Gesture_Done){
action_timelist.add(System.currentTimeMillis());
evaluate_actionlist(false);
}
Gesture_Done=false;
}
else if(isMoved){
xMoved = xPressed - event.getX();
yMoved = yPressed - event.getY();
checkGesture();
}
return false;
}
Cause there’s no error displayed, i have no idea how to fix it..
Try using the edited code below. I had the exact same problem just a couple of hours ago, and it was because I returned false even though I was consuming the touch events. The code below returns true if you act on the event, false otherwise.