現在、NavigationDrawerとして主なアクティビティを使ってアプリケーションを行っています。だから、私のアプリケーションをナビゲートするために、他の "アクティビティ"はフラグメントであり、断片の1つでは、私はGoogleMapサポートフラグメントを置く必要があります。ポイントは、私のフラグメントでは、私はgetFragmentManager.findFragmentById(R.id.map);
を返すときnullを返します。フラグメント内にGoogleマップサポートフラグメントを使用してください
私のコードは次のようになります。
//fragment_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
//My HomeFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home, container, false);
FragmentManager manager = getFragmentManager();
SupportMapFragment mapFragment = (SupportMapFragment)manager.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
return view;
}
これを修正する方法について誰にも分かりますか?私はすでにこのウェブサイトや他の多くのソリューションを探しましたが、私の "親"フラグメントのXMLレイアウトにフラグメントを格納する方法を理解できません。あなたの助けのための
おかげで、 真心を込め、 マチュー・ムニエ