getFragmentManager( ) and support package

2019-08-17 03:48发布

问题:

I'm learning to use fragments for build a dynamic application, but I've a problem with the Fragment Manager. When I pass it by the method getFragmentManager( ) is shown a warning because it returns the Fragment Manager of android.app, not from the support library. Do you know how to fix it?

回答1:

You should use getSupportFragmentManager() instead of getFragmentManager()

Also, make sure you are extending FragmentActivity and not just Activity.