0

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?

1 Answer 1

1

In order to get the following MotionEvents, you must return true in the onTouchEvent method.

source

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.