Map fragment V2 in a Fragment

后端 未结 4 569
粉色の甜心
粉色の甜心 2021-01-14 13:48

I am facing some issue\"Null pointer Expcepttion at getmap()\" in Google Map Fragments . I want to insert mapfragment in a fragment Please review the code and let know whet

4条回答
  •  一个人的身影
    2021-01-14 14:21

    Remove all the fmap code:

    SupportMapFragment fmap = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);
    
    if (fmap == null) {
        fmap = SupportMapFragment.newInstance();
        ft.add(R.id.map, fmap);
    }
    

    You already have an instance of the map saved as the "map" variable, so use that one.

提交回复
热议问题