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 trialNisarg Rajvi
Android Development Techdegree Student 130 Pointsthe constructor expects android.Support.v4.App.FragmentManager
Im having Android.App.Fragment with ViewPager but the FragmentPagerAdapter constructor expecting Android.Support.V4.App.FragmentManager. i tried compile 'com.android.support:support-v13:23.2.1' but still didnt work for me. maybe do i need to replace import statement in code? but which nd where?
1 Answer
kunalshitut
5,872 PointsYou need to include the v4 support library in your app's build.gradle file. For eg : compile "com.android.support:support-v4:18.0.+"
Sexual Potatoes
12,051 PointsThis does not work
Taylor Bryant
7,395 PointsTaylor Bryant
7,395 PointsYou need to make sure your import statement at the top does not say
import android.app.Fragment;
but instead says
import android.support.v4.app.Fragment;
then you need to use the getChildFragmentManager(); method as the argument for FragmentPagerAdapter
For example:
The reason for this is because you are using the support library for your viewpager so you need to use the support library for the fragment as well