cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function () {
        this.scrollCtrl = this.node.getChildByName("scrollview").getComponent("ListViewCommon");
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
    init: function() {
        this.scrollCtrl.setItemUpdateFunc(function(item, index) {
            this.updateItem = function(item, index, actualIndex, anotherActualIndex) {
                let label = item.getChildByName("label").getComponent(cc.Label);
                label.string = index + "~" + actualIndex + "~" + anotherActualIndex;
            };
        });

        for (let i = 0; i < 30; i++) {
            this.scrollCtrl.insertItem();
        }
    }
});
