2012-03-19 278 views
2

我目前正在尝试根据客户的规格创建应用程序,并且这些选项包括双选项卡集。Android:选项卡内的选项卡

这意味着用户需要点击底部的选项卡,例如在第一个选项卡中,他还会在顶部看到一组可供点击的选项卡(但点击这些选项卡时,只有顶部的标签将会改变,而底部的标签将保持不变)。

我该如何使用Android执行此操作? 到目前为止,我只能实现正常的标签创建根项目“TabHost”就像这样:

<?xml version="1.0" encoding="utf-8"?> 
<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" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" > 
     </FrameLayout> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" /> 
    </RelativeLayout> 

</TabHost> 

非常感谢提前!

+0

你为什么不能有tabhost在您的活动的布局文件中,当选项卡1将被选中时,要加载该选项卡?将activity_1设置为选项卡活动,您将发现第二个选项卡工作正常。 – Hiral 2012-03-19 12:26:44

+0

@手稿抱歉,但我不明白你的答案。我该怎么办? – noloman 2012-03-19 12:34:15

+0

当你点击其中一个标签时,你开始一个活动,对吗?在那个活动中,你将会有一个布局文件。我告诉你在那里也有tabhost,这样当你加载活动时,它会给你标签在标签内。 – Hiral 2012-03-19 12:49:38

回答

相关问题