onTouchEvent executes twice onTouchEvent executes twice android android

onTouchEvent executes twice


It executes for every event. In this case it would be for the ACTION_DOWN and ACTION_UP event. It will also execute for the ACTION_MOVE event many, many times.

To have it only execute in one event, do something like this:

switch(event.getAction()){  case MotionEvent.ACTION_DOWN:    ** CODE **     break;  case MotionEvent.ACTION_MOVE:    ** CODE **     break;  case MotionEvent.ACTION_UP:    ** CODE **    break;}


In the switch statement, return false for all the events you do not need.