TheLettuceMaster
TheLettuceMaster

Reputation: 15734

How to use Swipe Gestures on Android Fragments (with Tabs)

I saw an excellent guide in using gestures for Android app's.... over here.

However, I could not adapt it to my situation which is bit more complicated. I have a FragmentActivity with two inner Fragment classes (also using support library, tabs, and viewpager).

There are two tabs (one for each inner Fragment class). When you are on Tab One and swipe right to left, using Viewpager, it swipes to the right tab--that works good. What I want to add is this: If you are on tab one, and swipe from left-to-right, it simply finish()'s the activity and takes the user back to a ListActivitry where they came from.

I am not sure if the above linked question refers to this situation, but I sure couldn't get any of the suggestions to work. It seems I need to call this in the left tab fragment, and not the "parent" FragmentActivity? Can someone guide me on this?

Upvotes: 0

Views: 3059

Answers (1)

Georgy Gobozov
Georgy Gobozov

Reputation: 13731

You can use this approach to allow or deny pager intercept your swipes

 pager.requestDisallowInterceptTouchEvent(true)

Take a look at this post ViewPager intercepts all x-axis onTouch events. How to disable?

Upvotes: 2

Related Questions