local listView = ccui.ListView:create()
listView:setContentSize(cc.size(200, 200))
listView:setDirection(ccui.ListViewDirection.vertical)
listView:center():addTo(self)
listView:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid)
listView:setBackGroundColor(cc.c3b(0, 0, 255))
for i = 1, 5 do
local btn = ccui.Button:create("btn.png", "", "", 0)
btn:setTitleText("item" .. i)
btn:setScale9Enabled(true)
btn:addTouchEventListener(function(ref, eventType)
if cc.EventCode.ENDED == eventType then
print("touch" .. i)
end
end)
listView:pushBackCustomItem(btn)
end
listView:addScrollViewEventListener(function(sender, eventType)
print("ScrollView event:", eventType )
end)
listView:addEventListener(function(sender, eventType)
print("ListView event:", eventType)
end)