Android.Views.InflateException:二进制XML文件第1行:错误将表单中的Google地图的类片段膨胀

时间:2019-02-26 07:37:26

标签: forms xamarin

请在xamarin表单中使用布局填充自定义渲染的Xamarin表单解决此问题。

  

Android.Views.InflateException:二进制XML文件第1行:膨胀类片段时出错

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        class="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</FrameLayout>

C#代码

base.OnElementChanged(e);

var mFRaFragment = this.Context as FragmentActivity;

_view = mFRaFragment.LayoutInflater.Inflate(Resource.Layout.map_view, this, false);

mapFragment = mFRaFragment.FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map);

// mapFragment = mFRaFragment.FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map);

//mapFragment = SupportMapFragment.NewInstance();
//Android.Support.V4.App.FragmentTransaction fragmentTransaction = mapFragment.ChildFragmentManager.BeginTransaction();
//fragmentTransaction.Add(Resource.Id.map, mapFragment);
////fragmentTransaction.Commit();
//fragmentTransaction.Detach(mapFragment).Attach(mapFragment).Commit();

mapFragment.GetMapAsync(this);

0 个答案:

没有答案