陈梓泉
陈梓泉

Reputation: 145

What if I want to use ViewPager with support.v4.app?

The ViewPager is included in support library, all the methods of it require a parameter or a return of Fragment from support.v4.app, so I have to make sure all my fragments to extend support.v4.app.Fragment.

Can I use android.app.Fragmnet instead of support.v4.app.Fragment and how? Or how can I replace ViewPager?

Upvotes: 0

Views: 446

Answers (3)

Nicolas Buquet
Nicolas Buquet

Reputation: 3955

Yes you can: ViewPager is from android.support.v4 library, but you can use Adapters from android.support.v13 library to create its fragments.

FragmentPagerAdapter and FragmentStatePagerAdapter from android.support.v4 use android.support.v4.app.Fragment.

But FragmentPagerAdapter and FragmentStatePagerAdapter from android.support.v13 use regular android.app.Fragment.

android.support.v13.app.FragmentPagerAdapter android.support.v13.app.FragmentStatePagerAdapter

Upvotes: 1

A B
A B

Reputation: 338

As you can see here http://developer.android.com/training/animation/screen-slide.html, if using android.support.v4.view.ViewPager, you also have to use support.v4.app.Fragment.

Upvotes: 0

terencey
terencey

Reputation: 3332

As far as I know, you have to use support.v4.app.Fragment if you're using the support library's ViewPager.

Upvotes: 0

Related Questions