先附上git地址
https://github.com/huqiang0204/huqiang.UnitySubThreadUI
示例代码请看 ScrollExTestPage
可以绑定三种模型,头部,尾部,和中间数据部分
这里只用到了中间数据模型和头部模型
List
ScrollYExtand.DataTemplate tmp = new ScrollYExtand.DataTemplate();
tmp.Title = "test1";
List
for (int i = 0; i < 22; i++)
list.Add("tttt"+i.ToString());
tmp.Hide = true;
tmp.Data = list;
datas.Add(tmp);
tmp = new ScrollYExtand.DataTemplate();
tmp.Title = "test2";
list = new List
for (int i = 0; i < 11; i++)
list.Add("tttt" + i.ToString());
tmp.Hide = true;
tmp.Data = list;
datas.Add(tmp);
tmp = new ScrollYExtand.DataTemplate();
tmp.Title = "test3";
list = new List
for (int i = 0; i < 7; i++)
list.Add("tttt" + i.ToString());
tmp.Hide = true;
tmp.Data = list;
datas.Add(tmp);
view.scroll.BindingData = datas;
view.scroll.SetTitleUpdate
view.scroll.SetItemUpdate
view.scroll.Refresh();
头部数据更新
ScrollYExtand.DataTemplate current;
void TitleUpdate(TitleItem title, ScrollYExtand.DataTemplate data, int index)
{
title.Text.text = data.Title as string;
title.bk.DataContext = data;
title.bk.Click = (o, e) => {
var dt = o.DataContext as ScrollYExtand.DataTemplate;
if(dt.Hide)
{
view.scroll.OpenSection(dt);
if(current!=dt)
{
view.scroll.HideSection(current);
}
current = dt;
}
else
{
view.scroll.HideSection(dt);
if (dt == current)
current = null;
}
};
}
数据部分更新
void ItemUpdate(SubItem item,string data,int index)
{
item.Text.text = data;
}