云信duilib 学习一 VListBox 虚拟列表

 duilib 快速入门

duilib入门基础一 容器之 BOX、VBOX、HBOX布局及其子控件align排列方式

duilib入门基础二 HBOX容器内 子控件margin定位规则

​​​​​​duilib入门基础三 VBOX容器内 子控件margin定位规则

duilib入门基础四 BOX容器内 子控件margin定位规则

duilib入门基础五 简单示例之 文件选择框使用

duilib入门基础 六 见见世面,duilib 基本控件 Button 能实现的界面一览

duilib入门基础 七 见见世面,duilib 基本控件 复选框 单选框

duilib入门基础 八 见见世面,duilib 基本控件 滑动条

duilib入门基础 九 见见世面,duilib 基本控件 组合框

duilib入门基础 十 见见世面,duilib 基本控件 选项框 OptionBox

云信duilib基本控件示例下载

简单示例:

<?xml version="1.0" encoding="UTF-8"?>
<Window size="400,600" caption="0,0,0,35" sizebox="4,4,4,4">
  <VBox bkcolor="bk_wnd_darkcolor">
    <!-- <HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor"> -->
    <HBox width="stretch" height="35" >
      <Control />
      <Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0"/>
      <Box width="21" margin="4,6,0,0">
        <Button class="btn_wnd_max" name="maxbtn"/>
        <Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
      </Box>
      <Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
    </HBox>

   <HBox width="stretch" height="100" bkcolor="bk_wnd_darkcolor">

    </HBox>

    <VBox>
        <VListBox class="list" name="list" padding="20,3,20,3">
        </VListBox>
    </VBox>
  </VBox>
</Window>

    <Class name="list" bkcolor="bk_wnd_lightcolor" vscrollbar="true"/>
    <Class name="listitem" hotcolor="bk_listitem_hovered" pushedcolor="bk_listitem_selected" selectednormalcolor="bk_listitem_selected" fadehot="false" height="60" align="center" />
    <Class name="list_topitem" normalcolor="bk_topitem_normal" hotcolor="bk_topitem_hovered" pushedcolor="bk_topitem_selected" selectednormalcolor="bk_topitem_selected" fadehot="false"/>

代码:
 

void BasicForm::InitWindow()
{

	/* Initialize ListBox data */
	ui::ListBox* list = dynamic_cast<ui::ListBox*>(FindControl(L"list"));
	for (auto i = 0; i < 30; i++)
	{
		ui::ListContainerElement* element = new ui::ListContainerElement;
		element->SetText(nbase::StringPrintf(L"ListElement %d", i));
		element->SetClass(L"listitem");
	//	element->SetFixedHeight(20);
		list->Add(element);
	}

}

扩展

列表现一般是比较丰富的,这个只是最基本的文字样式,下面将其扩展

主要思想是 单独写一个ListContainerElement 布局文件

<?xml version="1.0" encoding="utf-8"?>
<Window>

    <ListContainerElement class="listitem" width="stretch" height="180" bkcolor="bk_wnd_darkcolor"  >     
        <VBox>
            <HBox name="storePushUrl" margin="0,0,0,0" childmargin="12" height="18">
                 <Control name="statusImg" width="auto" height="auto"/>
                 <Label name="live_status" text="正在直播..." font="system_14" normaltextcolor="textdefaultcolor" />
                 <Label  text="9:00--11:00" font="system_12" normaltextcolor="textdefaultcolor" name="time" />        
            </HBox>
            
            <Box name="storeRtmpUrl" bordersize="0">
                <HBox margin="30,1,0,0"  valign="center" bordersize="0">
                     <!-- 九宫格 设置拉伸范围 -->
                     <Control  height="160" normalimage="file='class_n.png' corner='20,20,20,20'"  hotimage="file='class_h.png' corner='20,20,20,20'"/>
                     <Control width="30" /> 

                </HBox>              
                <Box padding="8,20,0,20" width="auto" mouse="false">
                    <Control class="splitline_ver_level1" />
                </Box>
                <HBox  margin="30,0,0,0" height="120" width="678"  valign="center" bordersize="0"  mouse="false" mousechild="false">
                    <!-- 课程图 -->
                    <Box width="auto"  bordersize="0">
                        <Control name="classPhoto" width="200" height="120" bkimage="2.png" valign="top"/>
                        <Control bkimage="leftMask.png" width="auto"  height="120"/>
                    </Box>
                    <VBox childmargin="16" padding="20,20,0,0">
                        <Label text="本节知识点" font="system_16" name="chapterName" normaltextcolor="black" />
                        <Label text="课程题目" font="system_12" name="courseName" />
                        
                    </VBox>
                    <Control />
                </HBox>

                <!-- 进入按钮 -->
                 <Button class="btn_enter" name="enterLiveRoom_Btn" valign="center" halign="right" cursortype="hand" text="进入" />
            </Box>
        </VBox>
    </ListContainerElement>
</Window>

主窗口还是与之前一样

代码实现,加载这个自定义列表文件 ,

	/* Initialize ListBox data */
	ui::ListBox* list = dynamic_cast<ui::ListBox*>(FindControl(L"list"));
	for (auto i = 0; i < 30; i++)
	{
		//添加列表中
		ui::ListContainerElement* element = dynamic_cast<ui::ListContainerElement*>(ui::GlobalManager::CreateBoxWithCache(L"basic/my_list_item.xml"));
		
		list->Add(element);
	}

就可实现 丰富的自定义列表项

duilib云信table是基于duilib框架和云信SDK而创建的一个表格控件,用于在应用程序中展示和编辑表格数据。 duilib是一个开源的C++图形界面库,它提供了丰富的UI控件和界面布局管理功能,使开发者可以快速、灵活地构建界面。而云信SDK是网易公司开发的一套实时音视频通信解决方案,它提供了丰富的音视频通信功能,包括语音通话、视频通话、实时消息等。 duilib云信table结合了duilib的UI控件和云信的实时消息功能,使得开发者可以在应用程序中展示表格数据,并且可以通过实时消息功能实现对表格数据的实时更新和同步。 duilib云信table具有以下特点和优势: 1. 界面美观:duilib框架提供了丰富的UI控件和界面布局管理功能,开发者可以自由设计和定制表格的外观和样式,使得表格界面更加美观和符合用户需求。 2. 功能丰富:duilib云信table支持表格的显示、编辑、排序、过滤等常用功能,方便开发者对表格数据进行操作和管理。同时,云信SDK提供的实时消息功能可以实现对表格数据的实时更新和同步,方便多人协作和实时数据交互。 3. 扩展性强:duilib云信table是基于duilib框架和云信SDK的开发,开发者可以自由扩展和定制该控件的功能和行为,满足不同应用场景的需求。 总之,duilib云信table是一个功能强大、界面美观的表格控件,可以方便地展示和编辑表格数据,并通过云信SDK实现实时数据的更新和同步。它的出现为表格数据展示和管理提供了一种简单、高效的解决方案。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清水迎朝阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值