Question

Im trying to figure out how to see when a MotionEvent is done with an event (i.e, the user has pressed on the screen, dragged around, and took their finger off the screen). In the Docs i only see getEventTime to generate when the event started, but theres no mention on how to figure out when it finished. Any ideas?

Was it helpful?

Solution

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

@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 a lot of flags, Check this MotionEvent

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top