7

なぜタグフラグメントに予期しない名前空間プレフィックス「xmlns」が見つかりましたタグフラグメントに
予期しない名前空間プレフィックス「マップ」が見つかりましたか?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"

        map:mapType="satellite"/>
</RelativeLayout>

なぜタグフラグメントに予期しない名前空間プレフィックス「xmlns」が見つかりましたタグフラグメントに予期しない名前空間プレフィックス「マップ」が見つかりましたか?

4

3 に答える 3

18

要素から削除xmlns:android="http://schemas.android.com/apk/res/android"し、要素からルート要素に<fragment>移動することを検討してください。xmlns:map="http://schemas.android.com/apk/res-auto"<fragment>

たとえば、これは有効です。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/foo"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"
        map:mapType="satellite"/>

</RelativeLayout>
于 2013-05-09T11:43:03.353 に答える
2

明らかに、これは誤解を招くリント チェック エラーです。Eclipseの問題ビューで、エラーのある行を右クリックし、クイックフィックスオプションを選択して、プロジェクトのチェックを無視するなどを選択すると、それを削除できます。

エラーが解消され、プロジェクトがビルドされ、アプリが完全に正常に動作します。

于 2014-03-03T18:00:38.973 に答える
0

これを試して

 <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"

于 2013-05-09T11:45:20.537 に答える