I need to detect in my application when user stop moving across a specific view. I'm creating something similar to marque text in my application which can interact while user is touching the view and moving across it. And I need to start scrolling the view after user lifts his finger. As I notices if I move my finger across the view a few seconds and when I lift my finger the MotionEvent.ACTION_UP
is not called. The last event which I capture is ACTION_MOVE
. So how can I detect when user lifts his finger after moving across the view a few seconds? Is there some kind of function which can detect that?
Here is the code which I'm using :
txt.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, final MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.e("","event down : "+event.getAction());
handler.removeCallbacks(runnable);
break;
case MotionEvent.ACTION_UP:
Log.e("","event up : "+event.getAction());
if(myTimer!=null){
myTimer.cancel();
}
break;
case MotionEvent.ACTION_MOVE:
Log.d("","move");
// handler.removeCallbacks(runnable);
checkX();
break;
}
return true;
}
});
Thanks in advance!
I think the event may be sending an ACTION_CANCEL
action before the gesture is finished. Or, if it drags outside of the view you're checking, it could be ACTION_OUTSIDE
.
The best way to confirm/debug this would be to put a Log.d()
statement in, print the MotionEvent.getActionMasked()
value, and check to see what actions are being called after your ACTION_MOVE
event ends.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With