DominicM
DominicM

Reputation: 2196

Android: ListView with Swipe inside ViewPager

I have an activity with a ViewPager that covers the whole activity. Inside this ViewPager is a ListView, that only covers the bottom part of the fragment. The ListView recognizes swipe events (you can swipe Items left and right) but when you want to swipe a list item the ViewPager switches the page, so it doesn't work. Is there an easy way to deal with this problem, so that the ViewPager doesn't receive the touch events that are intended for the list.

Thanks

Upvotes: 1

Views: 6118

Answers (1)

evaristokbza
evaristokbza

Reputation: 872

My first idea is requestDisallowInterceptTouchEvent() may help you.

public boolean onTouch(View v, MotionEvent e) {
    if(e.getAction() == MotionEvent.ACTION_DOWN){
       listItem.getParent().requestDisallowInterceptTouchEvent(true);
    }
}

Upvotes: 4

Related Questions