I have a navigation drawer with some fragments. Each Fragment has a MapFragment in the layout. Initially, when the app runs the navigation drawer clicks open up the fragment once, but when I click the same navigation item to open up the same fragment second time (after visiting other fragments)I get the following error in the onCreateView()
Binary XML file line #1: Error inflating class fragment
Below is my code for the fragment:
user_map_Fragment.xml
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/parentContainer"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="200dp"
android:name="com.google.android.gms.maps.MapFragment"/>
......
</LinearLayout>
MainFragment.cs
public class MainFragement : Android.Support.V4.App.Fragment, IOnMapReadyCallback, ILocationListener, Android.Views.View.IOnKeyListener
{
private GoogleMap mMap;
private LocationManager _locationManager;
private string _locationProvider;
private Android.Locations.Location _currentLocation;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if (v == null)
{
v = inflater.Inflate(Resource.Layout.Main, container, false);
SetUpMap();
InitializeLocationManager();
}
return v;
}
}
private void SetUpMap()
{
if (mMap == null)
{
Activity.FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map).GetMapAsync(this);
}
}
Crash Log:
06-22 10:56:50.798 E/mono-rt (15470): java.lang.IllegalArgumentException: Binary XML file line #1: Duplicate id 0x7f0a0099, tag null, or parent id 0x7f0a007b with another fragment for com.google.android.gms.maps.MapFragment
06-22 10:56:50.798 E/mono-rt (15470): at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2136)
06-22 10:56:50.798 E/mono-rt (15470): at android.app.Activity.onCreateView(Activity.java:5516)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:34)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:78)
06-22 10:56:50.798 E/mono-rt (15470): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
06-22 10:56:50.798 E/mono-rt (15470): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
06-22 10:56:50.798 E/mono-rt (15470): at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
06-22 10:56:50.798 E/mono-rt (15470): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
06-22 10:56:50.798 E/mono-rt (15470): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
06-22 10:56:50.798 E/mono-rt (15470): at md5ec4b17f0066095dde498afe2bdaa8cb9.PeopleCheckinFragment.n_onCreateView(Native Method)
06-22 10:56:50.798 E/mono-rt (15470): at md5ec4b17f0066095dde498afe2bdaa8cb9.PeopleCheckinFragment.onCreateView(PeopleCheckinFragment.java:39)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1026)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
06-22 10:56:50.798 E/mono-rt (15470): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
06-22 10:56:50.798 E/mono-rt (15470): at android.os.Handler.handleCallback(Handler.java:739)
06-22 10:56:50.798 E/mono-rt (15470): at android.os.Handler.dispatchMessage(Handler.java:95)
06-22 10:56:50.798 E/mono-rt (15470): at android.os.Looper.loop(Looper.java:135)
06-22 10:56:50.798 E/mono-rt (15470): at android.app.ActivityThread.main(ActivityThread.java:5930)
06-22 10:56:50.798 E/mono-rt (15470): at java.lang.reflect.Method.invoke(Native Method)
06-22 10:56:50.798 E/mono-rt (15470): at java.lang.reflect.Method.invoke(Method.java:372)
06-22 10:56:50.798 E/mono-rt (15470): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
06-22 10:56:50.798 E/mono-rt (15470): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
How do I solve this?
Fragment
toFragment Activity
. – Prepossession