2013-02-19 89 views
0

我正在嘗試使用谷歌地圖爲android v2。我跟着從指令:谷歌地圖android v2 xml文件錯誤信息

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 2013-02-19 07:05:14

回答

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> 

它可以幫助你