Android.app Fragments vs. android.support.v4.app using ViewPager?
You can use ViewPager
with native fragments from the android.app
package with the adapters from the android.support.v13.app package. You have to use the v13 support jar for that.
There are two versions of the adapters that work with ViewPager
, the ones in the v4
package are meant to be used with support fragments, the ones in v13
with native fragments.
The reason why there are now two fragment implementations is historical: Fragments in the android.app
package were introduced with Android 3 for tablets only and the support library was created to bring fragments to phones running older versions. On Android 4 you have both.
From my own experience I would recommend using support fragments, even when developing for Android 4. Here are some reasons: Fragment or Support Fragment?
android.app.Fragment
class is deprecated since Android P (link), so only android.support.v4.app.Fragment
should be used everywhere.
If you're going to target API 11+, you won't need the support library [and your actual apk will be smaller, at least).
If you want to support anything before Android 3.x, you'll need the support library.
Is this what you're asking?