Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMuhammad Ali
7,192 PointsFragmentPageAdapter with Android.App.Fragment
I am using Android.App.Fragment with ViewPager. The FragmentPagerAdapter constructor expects Android.Support.V4.App.FragmentManager. But the Fragment class ChildFragmentManager is Android.App.Fragment Manager
4 Answers
Seth Kroger
56,413 PointsA version of FragmentPageAdapter that usable with non-support fragments is available in the v13 support library. You will need to include the library in your gradle file, compile 'com.android.support:support-v13:23.2.1'
If you're using it with a ChildFragmentManager the minSdk needs to be 17 or higher.
maivandahmadzai
3,467 Pointscompile 'com.android.support:support-v13:23.2.1'
does not work for me I still get the same error, my min sdk is 19.
Seth Kroger
56,413 PointsDid you replace the import statement in the code?
chandrashekhar singh
507 Pointsjava.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.view.ViewPager.setAdapter(android.support.v4.view.PagerAdapter)' on a null object reference i am getting this problem. I need help please.
maivandahmadzai
3,467 PointsYes, it did work for me. Thank you!
Nisarg Rajvi
Android Development Techdegree Student 130 Pointscan you provide me import statement?
Seth Kroger
56,413 Pointsimport android.support.v13.app.FragmentPagerAdapter;
It should replace the import statement for the v4 support version of that class, if any.
Nisarg Rajvi
Android Development Techdegree Student 130 PointsNisarg Rajvi
Android Development Techdegree Student 130 Pointscan u provide import statement i tried it but still getting same error. i think it must be wrong with import statement.
Abhinav Kanoria
7,730 PointsAbhinav Kanoria
7,730 PointsDo I need to use the import statement 'import android.support.v13.app.FragmentPagerAdapter;' instead of 'import android.support.v4.app.FragmentPagerAdapter;' ?? Only when I use the v13 version, I am able to use the method getChildFragmentManager() as a parameter in FragmentPagerAdapter().
Please reply fast!