Android:FragmentActivity内部的FragmentActivity(NavigationBar中的ScrollView) [英] Android: FragmentActivity inside FragmentActivity (ScrollView in NavigationBar)

查看:145
本文介绍了Android:FragmentActivity内部的FragmentActivity(NavigationBar中的ScrollView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个FragmentActivity,它可以通过ViewPager滑动几个片段,还有一个FragmentActivity,它承载一个ActionBar进行导航.

I have a FragmentActivity which can swipe through several fragments via ViewPager and a FragmentActivity which hosts an ActionBar for navigation.

现在,我想将FragmentActivity和ViewPager嵌套在另一个包含ActionBar的FragmentActivity的第一个片段中.

Now I want to nest the FragmentActivity with the ViewPager in the first fragment of the other FragmentActivity which hosts the ActionBar.

换句话说,我希望有一个ActionBar导航,在第一个选项卡中,我希望有可滑动的片段.

In other words I like to have an ActionBar navigation and in it's first Tab I'd like to have swipeable fragments.

我的问题是如何将一个FragmentActivity嵌套在另一个FragmentActivity中.两者都可以独立工作,但我不让他们一起工作.

My problem is how to nest one FragmentActivity in another FragmentActivity. Both work on their own but I don't get them to work together.

推荐答案

您可以为view-pager中的片段编写自己的触摸拦截器.

You can write your own touch interceptor for the fragments inside your view-pager.

不过,第二点意见,请参阅我的问题最低要求:

However on a second opinion, please see my moqup in the question:

您可以具有多个ViewGroup容器(最好是FrameLayout),在每个容器上都可以使用事务添加或删除片段.导航面板的容器与ViewPager的显示容器不同:

You can have several ViewGroup container preferably FrameLayout, where on each you can add or remove fragments using transactions. The container of the Navigation Panel is different than where the ViewPager is showing:

将此ViewPager保留在一个单独的片段中,该片段在另一个FrameLayout中生成.在ViewPager中,您不应使用FragmentPageAdapter,而应使用常规的PagerAdapter(避免片段嵌套).因此,ViewPager是视图的父容器,而不是显示它们的片段.

Keep this ViewPager in a separate fragment that spawns in yet another FrameLayout. in ViewPager here you should not use the FragmentPageAdapter, but a regular PagerAdapter (avoid nesting of fragments). Hence the ViewPager is a parent container for the Views, and not Fragments where they are shown.

导航抽屉的目标(在单击项目时)将是第二个FrameLayout.保持简单!

The target of the navigation drawer (on item click) will be this second FrameLayout. Keep it simple!!

类似地,您可以在基于Tab的ViewPager的第一个标签中包含一个ViewPager,其中包含这些新发现的信息.

Similarly you can have a ViewPager inside a first tab of Tab based ViewPager with this new found information.

这篇关于Android:FragmentActivity内部的FragmentActivity(NavigationBar中的ScrollView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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