使用listView有感

et listView = new ccui.ListView();
this.addChild(listView,9999);
listView.setDirection(ccui.ScrollView.DIR_VERTICAL);
listView.setTouchEnabled(true);
listView.setContentSize(cc.size(width,height));
listView.setScrollBarEnabled(false);
listView.setItemsMargin(0);

let layout = new ccui.Layout();
layout.setContentSize(cc.size(listView.width,listView.height/2));
listView.pushBackCustomItem(layout);//而非addChild

let labelTTF = new cc.LabelTTF('testString');
layout.addChild(labelTTF);
labelTTF.setPosition(layout.width/2,layout.height/2);

let imageView = new ccui.ImageView();
listView.pushBackCustomItem(imageView);//listView只能push进去ccui控件
listView.setItemModel(listView.getItem(0));
listView.pushBackDefaultItem();


posted @ 2019-12-12 14:59  流星曳尾  阅读(540)  评论(0编辑  收藏  举报