Cannot resolve method 'getSupportFragmentManager ( )' inside Fragment

后端 未结 14 736
别跟我提以往
别跟我提以往 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:38

    getSupportFragmentManager() is not part of Fragment, so you cannot get it here that way. You can get it from parent Activity (so in onAttach() the earliest) using normal

    activity.getSupportFragmentManager();
    

    or you can try getChildFragmentManager(), which is in scope of Fragment, but requires API17+

提交回复
热议问题