cocos2d-js listView用法

来源:互联网 发布:淘宝王者荣耀cdk靠谱吗 编辑:程序博客网 时间:2024/05/17 07:47

1.在cocos studio中添加listView。

2.在cocos studio中添加一个layout类型的listItem,设置为不可见。

3.在这个listitem中添加你要在listView中每一项显示的内容。

例如这样:

这个item中有文字,有图片image是layout类型。

4.在代码中调用:

(1)this.mode = this.endLayer.getChildByName("item");获取这个item

(2)然后获得这个item中的每一项进行赋值

var item = this.mode.clone();
        item.setVisible(true);
        var textLine = item.getChildByName("line");

(3)赋值完成后,调用这句this.endLayerList.pushBackCustomItem(item);加入listView。