文档开发者中心
我的

使用Tablist实现界面的切换效果问题

使用Tablist实现界面的切换效果,点击某tab后,界面空白,未显示所需界面,再次点击界面后出现界面内容。
点赞
收藏
回复
2
分享
举报
浏览402 发布于2021-06-16 07:24未知归属地
全部评论
最多点赞
最新发布
最早发布
开发者你好,参考如下:
收起
自动换行
深色代码主题
复制
() {
    (i = i < i++) {
        .add(+ i + )}
    = (TabList)findComponentById(ResourceTable.).setTabTextColors().setIndicatorType(TabList.).setSelectedTabIndicatorColor()LogUtil.()= (ListContainer) findComponentById(ResourceTable.)= MyProvider().setItemProvider().setItemLongClickedListener((listViewcomponentposid) -> {
        Object selectedItem = .getItem(pos)(selectedItem == ) {
            LogUtil.()}
        showDialog(pos)LogUtil.(+ pos + +id)}).setItemClickedListener(ListContainer.ItemClickedListener() {
        (ListContainer listContainerComponent componentil) {
            CommonUtil.(TableListAbilitySlice.+ i + )}
    })TabList.Tab tab1 = createTab()TabList.Tab tab2 = createTab()TabList.Tab tab3 = createTab()TabList.Tab tab4 = createTab()TabList.Tab tab5 = createTab()TabList.Tab tab6 = createTab()TabList.Tab tab7 = createTab()TabList.Tab tab8 = createTab()TabList.Tab tab9 = createTab().addTab(tab1).addTab(tab2).addTab(tab3).addTab(tab4).addTab(tab5).addTab(tab6).addTab(tab7).addTab(tab8).addTab(tab9).selectTab(tab1)}

TabList.Tab (String name) {
    TabList.Tab tab = .Tab()tab.setMinimumWidth()tab.setText(name)tab.setFocusableInTouchMode()tab.setFocusable(Component.FOCUSABLE)tab.requestFocus()ShapeElement ShapeElementNormal = ShapeElement()ShapeElementNormal.setRgbColor(RgbColor.())ShapeElement ShapeElementFocused = ShapeElement()ShapeElementFocused.setRgbColor(RgbColor.())ShapeElementFocused.setCornerRadius(UiUtil.())StateElement stateListDrawable = StateElement()stateListDrawable.addState([]{}ShapeElementNormal)tab}
收起
自动换行
深色代码主题
复制
<DirectionalLayout  xmlns:ohos="http://schemas.huawei.com/res/ohos"
                    ohos:id="$+id:root_1"
                    ohos:width="match_parent"
                    ohos:height="match_parent"
                    ohos:orientation="vertical"
                    ohos:layout_alignment="top">
    <TabList
            ohos:id="$+id:subtab_1"
            ohos:width="match_parent"
            ohos:height="36dp"
            ohos:top_margin="10dp"
            ohos:tab_margin="24dp"
            ohos:layout_alignment="center"
            ohos:text_size="20sp"
            ohos:selected_tab_indicator_color="#FFFFFF"
            ohos:selected_tab_indicator_height="2dp"
            ohos:orientation="horizontal"
            ohos:text_alignment="center"/>

    <ListContainer
            ohos:id="$+id:list_container"
            ohos:width="match_parent"
            ohos:height="match_parent"></ListContainer>

</DirectionalLayout>
展开全部
2楼回复于2021-06-21 09:49 未知归属地
开发者你好请提供详细信息或相关截图
1楼回复于2021-06-16 07:35 未知归属地
写回答
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
  • 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
  • 如您发布的内容为转载内容,请注明内容来源。

我要发帖子

了解社区公约,与您携手共创和谐专业的开发者社区。