Replace onTouch()and set the flag to ACTION_DOWN. Until ACTION_UPit is called after that, the user touches the screen.
boolean pressed = false;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
pressed = true;
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
pressed = false;
break;
}
return pressed;
}
source
share