【发布时间】:2012-04-24 16:09:57
【问题描述】:
我目前正在尝试根据客户的规格创建一个应用程序,其中包括一个双标签集。
意味着用户需要点击底部的一个标签,例如在第一个标签中,他还会在顶部看到一组标签,他可以点击(但是当点击这些时,只有那些顶部的选项卡会发生变化,而底部的选项卡将保持不变)。
如何使用 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>
提前非常感谢!
【问题讨论】:
-
为什么你的activity的布局文件中不能有tabhost,它是在tab-1被选中时加载的?将activity_1设置为tab Activity,你会发现你的第二个tabhost工作了。跨度>
-
@Hiral 抱歉,我不明白你的回答。我该怎么办?
-
当你点击其中一个选项卡时,你会启动一个活动,对吗?在那个活动中,你会有一个布局文件。我告诉你那里也有 tabhost,这样你什么时候加载活动,它会给你一个标签内的标签。
-
@Hiral 为所有这些创建片段会更简单吗?
-
对不起,我还没有使用片段!
标签: android android-layout tabs