SkinUI5.0官方文档

SkinUI5.0官方文档


列表框

<h2>列表节点</h2> <p>节点CListItem,继承于CRelativeLayout,支持CRelativeLayout的所有属性和方法。插入列表的节点必须是CListItem或其子类。</p> <h2>列表框</h2> <p>列表框CListView,继承于CScrollLayout,支持CScrollLayout的所有属性和方法。</p> <h2>属性和相关方法:</h2> <h4>设置列表为空时的提示图片</h4> <ul> <li>通过XML属性控制如下: <pre><code class="language-xml">EmptyImage="EmptyImage.png"</code></pre></li> <li>通过C++程序代码调用方法控制如下: <pre><code class="language-c">void SetEmptyImage(const String&amp; strEmptyImage);</code></pre></li> </ul> <h4>3.4 设置列表是否允许选中Item</h4> <ul> <li>通过XML属性控制如下: <pre><code class="language-xml">EmptyTips="IDS_EMPTY_TIPS"</code></pre></li> <li>通过C++程序代码调用方法控制如下: <pre><code class="language-c">void SetEmptyTips(const String&amp; strEmptyTips);</code></pre></li> </ul> <h2>请看下面的示例</h2> <h4>效果图</h4> <p><img src="http://www.skinui.cn/doc/img/5.0/3/ListView.png" alt="列表控件" /></p> <h4>简单列表框</h4> <pre><code class="language-xml">&lt;ListView Id="100" AlignParentLeft="40" Width="300" Height="200" AlignParentVertCenter="0"&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项1"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项2"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项3"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项4"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项5"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项6"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项7"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项8"/&gt; &lt;ListItem Width="MatchParent" Height="40" Layout="ListItem.xml" Background="ListItem.png" ChildText11="列表项9"/&gt; &lt;/ListView&gt;</code></pre> <h4>复杂列表框</h4> <pre><code class="language-xml">&lt;ListView Id="200" AlignParentLeft="40" Width="300" Height="240" AlignParentVertCenter="0"&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名1" ChildText3="消息消息消息消息消息消息消息消息1"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名2" ChildText3="消息消息消息消息消息消息消息消息2"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名3" ChildText3="消息消息消息消息消息消息消息消息3"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名4" ChildText3="消息消息消息消息消息消息消息消息4"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名5" ChildText3="消息消息消息消息消息消息消息消息5"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名6" ChildText3="消息消息消息消息消息消息消息消息6"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名7" ChildText3="消息消息消息消息消息消息消息消息7"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名8" ChildText3="消息消息消息消息消息消息消息消息8"/&gt; &lt;ListItem Width="MatchParent" Height="60" Layout="DemoListItem.xml" Background="ListItem.png" ChildImage1="Image.png" ChildText2="姓名9" ChildText3="消息消息消息消息消息消息消息消息9"/&gt; &lt;/ListView&gt;</code></pre> <h4>操作区</h4> <pre><code class="language-xml">&lt;FlexLayout Width="MatchParent" Height="WrapContent" Margin="40,0,20,20"&gt; &lt;Button Id="2001" Width="WrapContent" Height="WrapContent" Margin="0,0,20,0" Background="Button.png" Layout="Button.xml" ChildText11="插入数据"/&gt; &lt;Button Id="2002" Width="WrapContent" Height="WrapContent" Margin="0,0,20,0" Background="Button.png" Layout="Button.xml" ChildText11="滚到顶部"/&gt; &lt;Button Id="2003" Width="WrapContent" Height="WrapContent" Margin="0,0,20,0" Background="Button.png" Layout="Button.xml" ChildText11="滚到底部"/&gt; &lt;/FlexLayout&gt;</code></pre> <h4>h文件</h4> <pre><code class="language-cpp">#pragma once class CDemoListViewLayout : public CScrollLayout { public: enum { IDC_LISTVIEW = 200, IDC_BUTTON_CLOSE = 2000, IDC_BUTTON_INSERT = 2001, IDC_BUTTON_SCROLL_TOP = 2002, IDC_BUTTON_SCROLL_BOTTOM = 2003, }; public: CDemoListViewLayout(CView* pParent); public: virtual void OnBuildFinish(); protected: void OnBtnClickedClose(UINT uNotifyCode, int nID, CView* pView); void OnBtnClickedInsert(UINT uNotifyCode, int nID, CView* pView); void OnBtnClickedScrollTop(UINT uNotifyCode, int nID, CView* pView); void OnBtnClickedScrollBottom(UINT uNotifyCode, int nID, CView* pView); SKINUI_DECLARE_MESSAGE_MAP() private: CListView* m_pListView; SKINUI_DECLARE_DYNCREATE(CDemoListViewLayout, CScrollLayout) };</code></pre> <h4>cpp文件</h4> <pre><code class="language-cpp">#include &lt;stdafx.h&gt; #include "DemoListViewLayout.h" SKINUI_BEGIN_MESSAGE_MAP(CDemoListViewLayout, CScrollLayout) ON_SKINUI_COMMAND(IDC_BUTTON_CLOSE, OnBtnClickedClose) ON_SKINUI_COMMAND(IDC_BUTTON_INSERT, OnBtnClickedInsert) ON_SKINUI_COMMAND(IDC_BUTTON_SCROLL_TOP, OnBtnClickedScrollTop) ON_SKINUI_COMMAND(IDC_BUTTON_SCROLL_BOTTOM, OnBtnClickedScrollBottom) SKINUI_END_MESSAGE_MAP() CDemoListViewLayout::CDemoListViewLayout(CView* pParent) : CScrollLayout(pParent) , m_pListView(NULL) { } void CDemoListViewLayout::OnBuildFinish() { CScrollLayout::OnBuildFinish(); m_pListView = dynamic_cast&lt;CListView*&gt;(GetChildById(IDC_LISTVIEW)); } void CDemoListViewLayout::OnBtnClickedClose(UINT uNotifyCode, int nID, CView* pView) { if(m_pListView) { CListItem* pListItem = dynamic_cast&lt;CListItem*&gt;(pView-&gt;GetParent()); if(pListItem) { CRedrawLocker locker(m_pListView); m_pListView-&gt;DeleteChild(pListItem); m_pListView-&gt;Layout(); } } } void CDemoListViewLayout::OnBtnClickedInsert(UINT uNotifyCode, int nID, CView* pView) { static int nIndex = 10; if(m_pListView) { CListItem* pListItem = new CListItem(m_pListView); if(pListItem) { CRedrawLocker locker(m_pListView); pListItem-&gt;SetBackground(_T("ListItem.png")); pListItem-&gt;SetLayout(_T("DemoListItem.xml")); pListItem-&gt;SetHeight(ITEM_HEIGHT_60); pListItem-&gt;SetChildImage(1, _T("Image.png")); pListItem-&gt;SetChildText(2, SkinUI::Format(_T("姓名%d"), nIndex++)); pListItem-&gt;SetChildText(3, SkinUI::Format(_T("消息消息消息消息消息消息消息消息%d"), nIndex)); m_pListView-&gt;Layout(); m_pListView-&gt;ScrollBottom(); } } } void CDemoListViewLayout::OnBtnClickedScrollTop(UINT uNotifyCode, int nID, CView* pView) { if(m_pListView) { CListItem* pListItem = new CListItem(m_pListView); if(pListItem) { CRedrawLocker locker(m_pListView); m_pListView-&gt;ScrollTop(); } } } void CDemoListViewLayout::OnBtnClickedScrollBottom(UINT uNotifyCode, int nID, CView* pView) { if(m_pListView) { CListItem* pListItem = new CListItem(m_pListView); if(pListItem) { CRedrawLocker locker(m_pListView); m_pListView-&gt;ScrollBottom(); } } }</code></pre>

页面列表

ITEM_HTML