3

私は多くのマップの例でこのようなコードに出くわしました:

<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=".MainActivity" >

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

</RelativeLayout>

しかし、それらすべてのために、それは私がエラーを得ることになります

説明リソースパス場所タイプタグフラグメントに予期しない名前空間プレフィックス「xmlns」が見つかりましたactivity_msmap.xml/example / res /layout8行目AndroidLintの問題

ラインで

<fragment xmlns:android="http://schemas.android.com/apk/res/android"

だから...ここで何が起こっているのですか?どこの例でも見られますが、Eclipse / Androidでエラーが発生しますか?また、親要素でも定義されているのに、なぜ同じxml名前空間を繰り返すのですか?

4

1 に答える 1

8

xmlレイアウトで名前空間を2回定義することはできません。フラグメントから削除するだけで、RelativeLayoutはすでにxmlns:android名前空間を定義しています。

<fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />
于 2013-03-09T02:03:40.247 に答える