2013-05-09 51 views
7

爲什麼意外的名稱空間前綴爲標籤片段找到「xmlns」
爲標籤片段找到了意外的名稱空間前綴「map」?爲標籤片段找到意外的名稱空間前綴「xmlns」爲標籤片段找到意外的名稱空間前綴「map」

<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」找到的標籤斷 意外的命名空間前綴「地圖」找到的標籤斷?

回答

18

<fragment>元素中刪除xmlns:android="http://schemas.android.com/apk/res/android",並考慮將<fragment>元素中的xmlns:map="http://schemas.android.com/apk/res-auto"移動到根元素。

例如,這是有效的:

<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> 
+0

然後爲標籤片段找到「Unexpected namespace prefix」map「 – 2013-05-09 11:51:56

+0

@ Mr.Strolling:查看更新的答案 – CommonsWare 2013-05-09 12:01:25

+0

仍然意外的命名空間前綴**映射**找到標籤片段 – 2013-05-09 12:13:46

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" 

2

顯然,這僅僅是一個錯誤導致皮棉檢查錯誤。您可以在Eclipse的問題視圖中右鍵單擊帶有錯誤的行,選擇快速修復選項並選擇例如忽略檢查項目

錯誤消失,項目建立並且應用程序運行良好。

+1

清理該項目也擺脫了這個錯誤 – Price 2014-06-23 08:27:24