If you accidentally tap and want to drag and release and cancel
How do I go through a touch event?
Normally, I only need to use ClickListener, but I also want to implement touch events
In the case below, even if it's out of range, it's still processing 123
Normally, I only want to do one or two actions, but only when I cancel
(Action_MOVE is included in this program.)
@Override
public boolean onTouch (View view, MotionEvent event) {
switch(event.getAction()) {
caseMotionEvent.ACTION_DOWN:
// Processing.1
break;
caseMotionEvent.ACTION_UP:
// Processing.2
break;
}
return false;
}
@ Override
public void onClick (View view) {
// Processing.3
}
If the switch statement in the touch event is largely bound by the if statement and false, do not switch it.
I think I can do it, but how are you doing?
Also, is there a way not to implement ClickListener?
Thank you for your cooperation
android java
If I were you, I would only use onTouch, and I would branch the inside of processing 2 with if.
Use event.getX(), event.getY() in process 1 and process 2 to obtain the position when tapped and separated.Then, in Action 2, compare the valid range of the tap (which is calculated in advance) and perform Action 2 if it is valid and Action 3 if it is out of range.
© 2024 OneMinuteCode. All rights reserved.