2013-06-07 6 views
6

많은 조사를 한 후 아무 것도 찾지 못했습니다 ... 빠른 질문, Android Studio에서지도 태그를 사용하지 않는 이유는 누구에게 있나요? 아래 코드는 SDK의지도 샘플 조각입니다. 이미 구글 플레이 서비스 lib 및 지원을 추가했지만, 아무것도.Android Studio : xmlns :지도가 작동하지 않습니다.

그것은 오류를 사전에

Unexpected namespace prefix "map" found for tag fragment. 

감사를 많이 보여주는 것!

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

이 이클립스 버그 같은 많은 소리 : 상단의 버튼과 오류없이 내 작업 맵 레이아웃의

https://code.google.com/p/android/issues/detail? id = 53283 – CommonsWare

+0

그래서 유일한 해결책은 XML 코드 대신 java 코드에서 수행하는 것입니다. 감사합니다! – davidcv5

+0

예, AFAIK를 작동시키는 유일한 방법은 Java 코드를 사용하는 것입니다. 이 버그는 언젠가는 고쳐질 것입니다. – CommonsWare

답변

0

이 문제가 발생했습니다. 나는 Project/Clean을 수행했고 오류가 사라졌으며 이제는 제대로 작동합니다. 여기서는 맵 네임 스페이스가 사용중인 위치 위에 올바르게 정의되어 있다고 가정합니다.

0

저는 0.5.8을 실행 중이며 XML 뷰어는지도로 attrs에 밑줄을 긋고 있습니다. - 그러나 앱이 잘 구축되고 있습니다. YMMMV.

2

지도 조각을 FrameLayout으로 이동하면 동일한 문제가 발생합니다 (따라서지도 위에 버튼을 추가 할 수 있음).

내가 안드로이드 애플 리케이션과 XML의 멍청한 놈이야 나는 정말 무슨 짓을했는지 모르겠지만, 나는 내가 포함 트릭을 만들려고

:-) 해결책을 발견 보인다 조각을 별도의 파일에서 ('include'지시어를 사용하여) 한 번만 네임 스페이스 정의없이 베어 메 트리 조각을 넣으면 2 개의 옵션을 제안했습니다. xmlns : map = "http://schemas.android.com/apk/res- auto " xmlns : map ="http://schemas.android.com/tools " 원본 파일에서 Android Studio가 제안하지 않았지만 1 번째 파일 만 원래 파일에서 작동하지만 하나 대신).

결론 : 의 xmlns :지도 = "http://schemas.android.com/apk/res-auto"이와 : 의 xmlns :지도 = "HTTP : // 스키마 그냥이 줄을 변경합니다. android.com/tools "

내가 언급했듯이 - 나는 NOOB이고 나의 해결책은 몇 가지 부작용이 있습니다. 그래서 알아두면 좋겠지 만 (모든 것이 지금까지 잘되어 가고있는 것 같지만 ...).

<?xml version="1.0" encoding="utf-8"?> 
 

 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" 
 
       
 
    xmlns:map="http://schemas.android.com/tools" 
 
       
 
    tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:background="@color/purpura_E51B4A"> 
 

 
<fragment 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:id="@+id/map" 
 
    android:name="com.google.android.gms.maps.MapFragment" 
 

 
    map:cameraTargetLat="51.513259" 
 
    map:cameraTargetLng="-0.129147" 
 
    map:cameraTilt="30" 
 
    map:cameraZoom="13" 
 
    /> 
 

 
<Button 
 
    android:id="@+id/startActivityButton" 
 
    android:layout_width="wrap_content" 
 
    android:layout_height="wrap_content" 
 
    android:gravity="center_horizontal|center_vertical" 
 
    android:onClick="cokolwiek" 
 
    android:text="Baton z dupy" 
 
    android:layout_alignParentBottom="true" 
 
    /> 
 

 
</FrameLayout >

+0

xmlns : map = "http://schemas.android.com/tools"이 나를 속였습니다. –

+0

이것은 "지도"라는 이름의 "도구"네임 스페이스 일뿐입니다. 그것은 동일하지 않습니다. – alexpfx

관련 문제