Cannot resolve method 'getSupportFragmentManager ( )' inside Fragment

后端 未结 14 729
别跟我提以往
别跟我提以往 2020-12-01 05:16

I found the message Cannot resolve method \'getSupportFragmentManager ( )\' I want to fragment as activity. because I want to use Maps on the tabs swipe.

pub         


        
14条回答
  •  醉梦人生
    2020-12-01 05:41

    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.

提交回复
热议问题