簡體   English   中英

令人費解的Android xmlns錯誤

[英]Puzzling Android xmlns error

我在許多地圖示例中遇到過這樣的代碼:

<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 / layout line 8 Android Lint問題

在線

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

那么......這里發生了什么? 我在各地的例子中看到它,但它導致我的Eclipse / Android出錯? 另外,為什么在父元素中也定義了同樣的xml命名空間?

您無法在xml布局中兩次定義命名空間。 只需從片段中刪除它,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" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM