使用FragmentActivity使用类夸大类片段的错误

问题描述 投票:0回答:3

我已经在Google Maps中编码了一个Xamarin应用程序,并且收到此错误:

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

运行以下代码行时出现此错误:

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>

该命名空间称为:SimpleMapDemo

这是我的课堂宣言:

public class MapWithMarkersActivity : Android.Support.V4.App.FragmentActivity

我正在使用SupportMapFragment对象显示Google Map

我可以帮助您使此代码正常工作吗?

android-layout android-fragments xamarin android-fragmentactivity inflate-exception
3个回答
0
投票

我认为问题出在您在fragment元素上设置的class属性。您是否厌倦了没有它的布局的膨胀?


0
投票

我已经自己弄清楚了。我的班级名称不正确。

这里是正确的布局代码:

<?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>

-1
投票

我遇到了同样的问题,并通过删除VS或XS中obj / Debug / android目录中的AndroidManifest并将其重写以使其仅对我有效,来解决此问题

这是因为该应用无法区分Google Play服务清单和该应用的清单。

© www.soinside.com 2019 - 2024. All rights reserved.