سؤال

I have been looking for this all day. And I've have read through the Android Developer references aswell.

I would like the following structure in my xml.

<LinearLayout>
    <fragment />
    <fragment />
</LinearLayout>

The following LinearLayout shall be ONE PAGE. The problem here is that FragmentPageradapter wants ONE fragment in return, I the screen to include TWO Fragments.

Is this even possible? There is no documentation on it in on Android Developer. The closest thing is the Dynamic UI however that has nothing to do with including a FragmentPageradapter.

هل كانت مفيدة؟

المحلول

As of API 17 (and backported in the support library), there is getChildFragmentManager() in the Fragment class. This lets a Fragment contain Fragments. So, one option here is to create a parent Fragment that sets up the layout with two child Fragments. Then the FragmentPagerAdapter only needs to know about the parent.

A second option would be to create your own customer PagerAdapter that has unique knowledge of how to handle your desired layout.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top