SupportMapFragment does not support AndroidX Fragment

后端 未结 10 1603
傲寒
傲寒 2020-11-30 11:04
import com.google.android.gms.maps.SupportMapFragment;
import androidx.fragment.Fragment;
...
private SupportMapFragment mMapFragment;
...
mMapFragment = (SupportMap         


        
10条回答
  •  误落风尘
    2020-11-30 11:27

    I had this issue too. It is really not nice, and for sure temporary, but that was the only way I could make it work. So at least it unblocked me until it gets fixed.

        final Object mf = getChildFragmentManager().findFragmentById(R.id.map);
        if (mf instanceof SupportMapFragment) {
            final SupportMapFragment smf = (SupportMapFragment) mf;
            // ...
        } else {
            //handle
        }
    

    It works both compiler time and runtime.

提交回复
热议问题