Cannot resolve method 'getSupportFragmentManager ( )' inside Fragment

For my case, I made sure that Fragment class is imported from

android.support.v4.app.Fragment

Not from

android.app.Fragment

Then I have used

getActivity().getSupportFragmentManager();

And now its working. If I use activity instance which I got in onAttach() is not working also.


Extends FragmentActivity instead of Activity


Use getActivity().getSupportFragmentManager()


Inside a Fragment subclass you have to use getFragmentManager in place of getSupportFragmentManager. You will get the support one if the import are from the support library.