문제 설명
Google지도 조각을 찾을 수 없습니다 (Can't find google maps fragment)
탭 안에 map
을 만드는 데 문제가 있습니다. getActivity().getSupportFragmentManager().findFragmentById(R.id.map)
null을 반환
합니다. getChildFragmentManager().findFragmentById(R.id.map)
로 대체하더라도.
나는 이것에 상당히 익숙하므로 다른 곳에서 뭔가 잘못되었을 수 있지만 그것이 무엇인지 전혀 모릅니다.
code
public class FragmentMap extends Fragment implements OnMapReadyCallback
@Override
public void onStart() {
super.onStart();
mMapFragment = (SupportMapFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
mMapFragment.getMapAsync(this);
}
xml
<?xml version="1.0" encoding="utf‑8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
참조 솔루션
방법 1:
change
android:name="com.google.android.gms.maps.MapFragment"
to
android:name="com.google.android.gms.maps.SupportMapFragment"