Learning about the completion of MotionEvent

I am trying to figure out how to see when a MotionEvent is executing with an event (i.e. the user clicked on the screen, dragged it and removed his finger from the screen). In Docs, I only see getEventTime to generate when the event fires, but it doesn't mention how to figure out when it will end. Any ideas?

+4
source share
1 answer

There is a flag MotionEvent.ACTION_UP and MotionEvent.ACTION_DOWN
You can check by comparing it with event.getAction()
you can use this as

 @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: //now touched break; case MotionEvent.ACTION_UP: //your code break; } } 

There are many flags. Check MotionEvent

+5
source

Source: https://habr.com/ru/post/1335584/


All Articles