0

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

Android.Views.InflateException: Binary XML file line #1: Error inflating class fragment

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

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对象来显示谷歌地图

我可以请一些帮助以使此代码正常工作吗?

4

3 回答 3

0

我认为问题在于您在片段元素上设置的类属性。您是否厌倦了没有它的布局?

于 2014-05-18T22:03:03.493 回答
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>
于 2014-05-20T05:51:40.577 回答
-1

我遇到了同样的问题,并通过在 VS 或 XS 中删除 obj/Debug/android 目录中的 AndroidManifest 并重写它来修复它,使其仅适用于我

那是因为应用程序无法区分谷歌播放服务清单和应用程序的清单。

于 2015-09-27T12:12:09.553 回答