Using ViewPager with native Fragments

Can't seem to find a solution to this problem. I'm creating an Android app which uses Fragments. So far I've been using the native ones as opposed to the support library ones because I'm aiming the app at the Nexus 7. However I've no problem using the support library if it makes no difference to development (I read something about no ActionBar?).

My problem is that I want to have a fragment that fills half the screen and shows a swipeable tabs type area. I want the user to be able to swipe left and right and be shown different Fragments for each "page" (Nested Fragments I know but I read that they're supported now). Basically I want it to be like the Play Store when you're swiping between Top Paid, Top Free etc. except only take up half the screen (which I achieve using a Fragment), the other half of the screen is another Fragment I have already written. Another thing is that within each "page" (such as Top Free etc.) I want to have 2 ListViews.

我试图实现的原始绘图

However it seems that the ViewPager component is only part of the support libraries which I think means I have to change all of my fragments to the support ones. Is this the only way to achieve this layout? There must be an easier way; I've seen something called the Workspace on a Google I/O video before so I assumed it's a very common UI design pattern.

Thanks


You want the ViewPager, and switching your fragments to support library ones is a very easy conversion.

And you'll probably want this for more customization :) http://viewpagerindicator.com/


You can use ViewPager with native fragments, there are adapters for it in the android.support.v13.app package. You need the v13 support jar to be able to use them.

But there might be advantages with using support fragments anyway: Fragment or Support Fragment?

链接地址: http://www.djcxy.com/p/11686.html

上一篇: 程序化的截图歪曲最近

下一篇: 将ViewPager与本机碎片一起使用