我在活動中有2個選項卡,並且我想添加一個新選項卡並添加一個Google地圖,所以我需要創建一個擴展了mapactivity的活動。到現在爲止還挺好。 但我不知道如何選擇標籤才能顯示地圖。調用另一個不同活動的活動中的選項卡
這是我的代碼
TabHost tabhost =(TabHost)findViewById(R.id.tabHost); tabhost.setup();
TabSpec spec1 = tabhost.newTabSpec("tab1");
spec1.setContent(R.id.tab1);
TabSpec spec2 = tabhost.newTabSpec("tab2");
spec2.setContent(R.id.tab2);
TabSpec spec3 = tabhost.newTabSpec("map");
spec3.setContent(R.id.tab3);
tabhost.addTab(spec1);
tabhost.addTab(spec2);
tabhost.addTab(spec3);
標籤1和片2正在作爲碼是所有在相同的活性。
有幫助嗎?
我正在使用蜂窩。那是問題嗎?你能給我一個示例代碼嗎?我是否必須更改所有的代碼,因爲它已經接近準備好了。我只需要添加此標籤與谷歌地圖。 – Adnama 2012-01-05 10:28:05
如果您使用的是蜂巢,您可以使用碎片。 我認爲如果你正在開發蜂窩或更高版本,你應該使用片段。 [這裏](http://developer.android.com/guide/topics/fundamentals/fragments.html)是開始使用片段的一些信息。 – 2012-01-05 11:02:27