I would like an android button to be triggered if a user drags across it and releases his finger on it in addition to the standard activation if it is clicked and released.
I was trying to use the ACTION_MOVE MotionEvent, but this event is only triggered between ACTION_DOWN and ACTION_UP events. I also think that ACTION_OUTSIDE might be a solution. Is there a way to do this?
Here is my code with the actions taken stripped out (b is a button):
b.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction()== MotionEvent.ACTION_DOWN){
//Tiggers correctly
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
//Triggers correctly between events, but not when the finger is dragged ontop outside of the element
} else if (event.getAction() == MotionEvent.ACTION_OUTSIDE){
//Can't get this to trigger in any case but I think it might be the solution
} else if (event.getAction() == MotionEvent.ACTION_UP){
//Triggers correctly
}
}
return false;
}
});