0

私はアンドロイドv2のためのグーグルマップで作業しようとしています。私はからの指示に従いました:

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

私は(上記のWebページの)一番下にあり、「マップを追加」と表示されています。次のコードをコピーして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>

なぜこれは整形式ではないのですか?

編集:LinearLayoutから「xmlns:android = "http://schemas.android.com/apk/res/android」を削除しようとしましたが、違いはありません。

4

1 に答える 1

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>

それはあなたを助けるかもしれません。

于 2013-02-19T06:28:57.987 に答える