Android layout 使用FragmentActivity使用类膨胀类片段时出错
我在Xamarin中编写了一个Google Maps应用程序,并收到以下错误: Android.Views.InflateException:二进制XML文件第1行:错误 膨胀类片段 我在运行以下代码行时遇到此错误:Android layout 使用FragmentActivity使用类膨胀类片段时出错,android-layout,android-fragments,xamarin,android-fragmentactivity,inflate-exception,Android Layout,Android Fragments,Xamarin,Android Fragmentactivity,Inflate Exception,我在Xamarin中编写了一个Google Maps应用程序,并收到以下错误: Android.Views.InflateException:二进制XML文件第1行:错误 膨胀类片段 我在运行以下代码行时遇到此错误: SetContentView(Resource.Layout.MapWithOverlayLayout); 这是我的MapWithOverlayLayout.axml布局文件: <?xml version="1.0" encoding="utf-8"?> <Li
SetContentView(Resource.Layout.MapWithOverlayLayout);
这是我的MapWithOverlayLayout.axml布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment class="SimpleMapDemo.MapWithMarkersActivity"
android:id="@+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
我正在使用SupportMapFragment对象来显示Google地图
我能为这段代码提供一些帮助吗?我认为问题在于您在fragment元素上设置的class属性。你厌倦了在没有它的情况下对布局进行膨胀吗?我自己已经弄明白了。我没有正确的类名 以下是正确的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
我也遇到了同样的问题,并通过删除obj/Debug/android目录中VS或XS中的AndroidManifest并重写它来修复它,从而使它只对我有效 这是因为应用程序无法区分google play服务清单和应用程序的清单
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>