SupportMapFragment does not support AndroidX Fragment

后端 未结 10 1600
傲寒
傲寒 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:33

    Make sure that in the fragment java class you import androidx.fragment.app.Fragment; and in the java class from where you refer to this particular fragment, you also import Fragment the same way i.e. import androidx.fragment.app.Fragment;

    After that to get a reference of the fragment we created, use getSupportFragmentManager().findFrgmentById(R.id.fragment_id).

    To summarise, make sure you have the same import in all concerned Java or Kotlin classes.

提交回复
热议问题