如何使用在Android碎片滑动手势(含标签) [英] How to use Swipe Gestures on Android Fragments (with Tabs)

查看:324
本文介绍了如何使用在Android碎片滑动手势(含标签)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android应用的手势看见一位优秀导游....在这里

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

不过,我无法使它适应我的情况是有点复杂。我有两个内部片段类(同样使用支持库,标签和viewpager)。

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).

有两个选项卡(每个片段内部类)。当你在一个选项卡刷卡和从右到左,使用Viewpager,它挥笔到右边的选项卡 - 的作品好。的我想补充的是,这个如果您是在标签之一,刷卡由左到右,它只是完成()的活动并取用户返回到他们来自何处一个ListActivitry。

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.

我不知道如果上面的链接问题指的是这种情况,但我肯定不能得到任何的建议工作。看来我需要在左侧选项卡片段调用该方法,而不是父母FragmentActivity?有人能指导我一下吗?

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?

推荐答案

您可以使用此方法来允许或拒绝寻呼机拦截你挥笔

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

 pager.requestDisallowInterceptTouchEvent(true)

看看这个帖子<一个href=\"http://stackoverflow.com/questions/8122460/viewpager-intercepts-all-x-axis-ontouch-events-how-to-disable\">ViewPager拦截所有x轴onTouch事件。如何禁用?

这篇关于如何使用在Android碎片滑动手势(含标签)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆