【问题标题】:Fixed Tab inside fixed tab in AndroidAndroid中固定选项卡内的固定选项卡
【发布时间】:2014-05-08 17:21:42
【问题描述】:

我想在标签内添加标签,如下所示:

 ----------------------
|Tab 1 | Tab 2 | tab 3 |
-----------------------
| Sub tab 1 | Sub tab 2|
 ----------------------

每个Parent tab 有两个sub tab。我正在使用片段来显示父选项卡(Action Bar tab)。

我通过实现片段替换尝试了这一点,但 android 不支持 nested fragment(17 岁以上除外)。我该如何完成。请帮我解决这个问题。

<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.view.PagerTitleStrip
    android:id="@+id/pager_title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#33b5e5"
    android:textColor="#fff"
    android:paddingTop="4dp"
    android:paddingBottom="4dp" />

</android.support.v4.view.ViewPager>

【问题讨论】:

    标签: android android-fragments android-actionbar android-tabs android-tabactivity


    【解决方案1】:

    如果子选项卡是视图而不是片段,您也许可以这样做。注册 TabHost,TabWidget,一个 id 为 "@android:id/tabcontent" 的 FrameLayout,里面有不同的标签。

    【讨论】:

    • 你能解释一下吗?
    【解决方案2】:

    您可以将RadioButton 伪装成标签并添加任意数量的图层。这提供了比 android 内置版本更高的外观灵活性。 RadioGroup 确保一次只选择 1 个。 查看接受的答案Making buttons that look like tabs in android 以进行实施。

    【讨论】:

    • 你能解释一下吗?
    • 标签的基本功能是一次选择一个项目,并使用该信息您可以在页面的其余部分加载内容。
    • 你想让我把单选按钮放在片段里面吗?
    • 片段 XML 的外观如何?
    • 不要使用片段显示父标签。依次添加两层无线电组。从第一层获取值以更新第二层并从第二层获取值以对页面的其余部分执行您想要的操作。单选按钮只是一个图像,因此可以更改为选项卡按钮的活动/非活动图像。有很多关于如何做到这一点的例子,包括我链接的那个。
    猜你喜欢
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    • 2019-12-02
    • 2016-04-12
    • 1970-01-01
    相关资源
    最近更新 更多