finding out when a MotionEvent has finished
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 fin开发者_如何学JAVAger 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?
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
精彩评论