Android : Android - prevent swiping/dragging on touch event

on Saturday, July 5, 2014


I'm using the following code to detect taps on the screen, however I've noticed it responds to swipes and activates the code in the event handler several times, how do I stop this? Thanks.



@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int)event.getX();
if (x < viewWidth/2)
{
xDir -= 10;

}

else
{
xDir += 10;
}
return true;
}

0 comments:

Post a Comment