I have an onTouchListener
for my LinearLayout
of ListView
s and I am trying to use the ACTION_DOWN
and ACTION_UP
data to detect when a user has swiped to the next ListView
. However, the MotionEvent
never equals ACTION_DOWN
, although ACTION_UP
works perfectly. After a lot of googling, the only solution I could find is to return true when the event is called, but I was already doing that. Here is my onTouchListener
code
View.OnTouchListener mTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
downX = event.getX();
return true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
upX = event.getX();
if(userSwipedFarEnough)
doStuff()
return true;
}
return false;
}
};
I figured out what was happening, the scrollview for my listview was somehow stealing the action_down so it wasn't being called. I realized it when I had an empty listview and the scrolling worked.