我遇到了(我敢肯定)愚蠢的問題,可以使用另一組眼睛。谷歌地圖片段在ActionBar標籤(與ActionBarSherlock)
我有一個應用程序需要GoogleMaps顯示在應用程序的幾個地方。我有它在我的主要活動順利所示,所有遊戲庫到位,V2關鍵是所有設置,等等
我的(截)mapview.xml
樣子:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
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" />
正如我所說的,在主要活動上,我可以正確設置contentView並繪製地圖,沒有問題。
然而,在不同的活動中,我採取標籤:
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Add tabs
actionBar.addTab(actionBar.newTab().setText(R.string.map).setTabListener(this));
這裏就是我遇到了麻煩。在選項卡中選擇的傾聽者,我這樣做,我敢肯定是哪裏錯了(佈局是一個空的線性佈局):
GoogleMapFragment mapFragment = new GoogleMapFragment();
fragmentTransaction = supportFragmentManager.beginTransaction();
fragmentTransaction.addToBackStack(null);
fragmentTransaction.replace(layout.getId(), mapFragment);
fragmentTransaction.commit();
那地圖片段看起來像:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.map_view, null);
}
當運行時,我得到的各種誤差取決於我如何調整這一點,如
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #2: Duplicate id 0x7f040058, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
就像我說的,我敢肯定,這是錯誤的,好像我試圖誇大片段的兩倍,或者運行通過使用sa進入問題我在應用程序中的兩個位置片段。
在這一點上,我不知道如何解決它。任何建議將不勝感激。
這實際上就是一個重複: http://stackoverflow.com/questions/14124354/android-supportmapfragment-with-google-map-api-2-0-giving-error – 2013-03-13 04:13:07