我正在嘗試將谷歌地圖視圖添加到現有片段中。 繼從開發文檔中的說明,我已經列入我的片段下面的XML:將Google Maps Android v2添加到片段時發生IllegalArgumentException
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
然而,我最終每次都得到一個IllegalArgumentException:
02-28 18:54:21.133: E/AndroidRuntime(11300): Caused by: java.lang.IllegalArgumentException: Binary XML file line #158: Duplicate id 0x7f050019, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
02-28 18: 54:21.133:E/AndroidRuntime(11300):在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285) 02-28 18:54:21.133:E/AndroidRuntime(11300):在android。 view.LayoutInflater.createViewFromTag(Layout
對此有任何解決方法?
其實你試圖添加MapFragment(從你的代碼),而不是一個地圖視圖。我不認爲這是可能的,因爲片段被設計成坐在活動內部而不是其他片段。 – 2013-03-01 00:09:06
是否可以添加一個MapView,而不使用MapFragment?理想情況下,我只想將MapView作爲我的佈局的一部分,就像其他任何小部件一樣。謝謝! – munkay 2013-03-01 00:10:10
對於我所知的MapView是GoogleMaps API V1對象,不能在V2中使用。你究竟想達到什麼目的? – 2013-03-01 00:12:19