2013-02-19 2 views
0

Я пытаюсь работать с картами google для android v2. Я следовал инструкциям из:Google maps android v2 xml file error message

https://developers.google.com/maps/documentation/android/start

Я в нижней части (указанной выше веб-странице), где он говорит: «Добавить карту». Когда я скопировать и вставить следующий код в мой main.xml:

<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.MapFragment"/> 

Я поздоровался ошибкой по тегу LinearLayout, который говорит: «Разметка в документе после корневого элемента должна быть хорошо сформирован. "

Вот main.xml во всей своей полноте:

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

<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.MapFragment"/> 


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:padding="30dip"> 



    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginBottom="25dip" 
     android:text="@string/welcome" 
     android:textSize="24sp"/> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_weight="1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:hint="@string/edit_location"/> 

    <Button 
     android:id="@+id/find_me_button" 
     android:layout_weight="0" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/button_find_me"/> 

    </LinearLayout> 

Почему это не хорошо сформирован?

редактирования: Я попытался удалить «Xmlns: андроид =» http://schemas.android.com/apk/res/android»от LinearLayout, но это не делает разницы

+0

Вы исправить эту проблему.? – TamiL

ответ

3

Пожалуйста, попробуйте. это:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" 
android:padding="30dip"> 

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

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginBottom="25dip" 
    android:text="@string/welcome" 
    android:textSize="24sp"/> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_weight="1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:hint="@string/edit_location"/> 

<Button 
    android:id="@+id/find_me_button" 
    android:layout_weight="0" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/button_find_me"/> 

</LinearLayout> 

это может помочь вам