Android 如何实现多窗格布局

Android 如何实现多窗格布局,android,android-fragments,tabs,Android,Android Fragments,Tabs,我有一个扩展片段的类。在这个片段中我需要将选项卡放置在垂直方向。我已经阅读了几篇文章,但总的来说,它给出了如何在片段中实现水平选项卡 我的班级: public class Sample extends Fragment { private FragmentTabHost mTabHost; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedI

我有一个扩展
片段的类。在这个
片段中
我需要将
选项卡
放置在
垂直方向。我已经阅读了几篇文章,但总的来说,它给出了如何在
片段中实现
水平选项卡

我的班级:

public class Sample extends Fragment {

private FragmentTabHost mTabHost;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    mTabHost = new FragmentTabHost(getActivity());
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.fragment1);

    mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
            Test.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
            Test.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
            Test.class, null);

    return mTabHost;
}
}
我的XML如下所示:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:orientation="horizontal" >

    <FrameLayout

        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.3" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:visibility="invisible" />

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <LinearLayout
                android:id="@+id/fragment1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >


            <Button
                    android:id="@+id/one"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:onClick="tabHandler"
                    android:text="3" />

                <Button
                    android:id="@+id/two"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:onClick="tabHandler"
                    android:text="4" />

                <Button
                    android:id="@+id/song_id"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:onClick="tabHandler"
                    android:text="5" />
        </LinearLayout>
        </ScrollView>
    </FrameLayout>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.7" />
</LinearLayout>

</TabHost>

我得到的是水平放置的3个
选项卡


谁能帮我把这件事弄清楚吗。我对
选项卡的实现没有太多经验。

有人能帮我吗?非常感谢您的帮助。如果您不想在片段中实现水平选项卡,您需要做什么。你能画一张图表来解释你的图形界面吗?我想显示这样的东西:当我处理你的问题时,看看这个