2

XMLファイルにいくつかの変更を加えようとすると、新しい問題が発生しました:

彼女のコード:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <fragment
        xmlns:map="http://schemas.android.com/apk/res/android"
        map:id="@+id/map"
        map:name="com.google.android.gms.maps.MapFragment"
        map:layout_width="wrap_content"
        map:layout_height="250dp" />

</LinearLayout>

でエラーが発生しました

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

タグ フラグメントの予期しない名前空間プレフィックス「xmlns」

4

2 に答える 2

4

ここで役立つかどうかはわかりませんが、私の場合、RelativeLayout で名前空間を 1 回だけ宣言します。

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

     <fragment class="com.blablabla.MyFragment"
            android:id="@+id/fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</RelativeLayout>

上記のように、フラグメントで名前空間を再度宣言しません。私が知る限り、名前空間は親 ViewGroup で一度だけ宣言する必要があります

于 2013-05-12T20:24:59.800 に答える