I am trying the android motion event. However, I do not know why it cant go to > case MotionEvent.ACTION_MOVE:
Here is my codes.
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action){
case MotionEvent.ACTION_DOWN:
startX = (int)event.getX();
startY = (int)event.getY();
selecting=false;
break;
case MotionEvent.ACTION_MOVE:
selecting=true;
break;
case MotionEvent.ACTION_UP:
if(selecting){
endX = (int)event.getX();
endY = (int)event.getY();
selected=true;
}
selecting=false;
break;
}
}
No matter how I swipe and touch, even if I remove if(selecting) condition in case MotionEvent.ACTION_UP, it always show same output.
start: {498.0, 365.0}
end: {0.0, 0.0}
selecting: false
selected: false
After I change it to
public boolean onTouchEvent(MotionEvent event)
everything is okay. Can anyone explain to me why does it happen?
If possible, help me to solve this problem too. How to get the actual point when I touch on screen?