1
我已經寫了2個活動,現在我希望他們在一個tabHost(2個選項卡,每個選項卡中的活動)。Android tabhost與不同的活動
我看到了一些代碼,但沒有一個對我有好處。 2個活動很複雜,所以我無法將它們歸爲一類。
我該怎麼辦?
謝謝。
我已經寫了2個活動,現在我希望他們在一個tabHost(2個選項卡,每個選項卡中的活動)。Android tabhost與不同的活動
我看到了一些代碼,但沒有一個對我有好處。 2個活動很複雜,所以我無法將它們歸爲一類。
我該怎麼辦?
謝謝。
如果你能做到這一點,我的意思是同時加載多個活動,您將有記憶的問題,您應該使用標籤與Fragments
,所以我建議使用FragmentTabHost
,你的活動轉化爲Fragments
並在加載它FragmentTabHost
,這是一個例子:
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
<FrameLayout
android:id="@android:id/tab_content1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+id/tab_content2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
「2個選項卡,在卡上每一活動」 - 投入標籤活動用四年前**棄用的技術**。請使用現代選項卡解決方案('ViewPager'和選項卡式指示符,'FragmenTabHost'等)。 – CommonsWare 2015-03-02 22:14:18
我同意墨菲先生的看法,我的答案,在這裏你可以找到關於它的另一個問題http://stackoverflow.com/questions/15486686/load-different-activities-in-tabs – Jorgesys 2015-03-02 22:23:35