当前位置:网站首页>Listview pull-down loading function
Listview pull-down loading function
2022-07-05 04:56:00 【Meteor spot】
function LoginScene:init()
self._index = {1,2,3,4,5,6,7,8} -- Set the test text displayed
self._index_len_init = 1 -- Join in listview The initial index of
self._index_len_end = #self._index -- Join in listview End index of , The purpose is to prevent repeated loading , If you have already loaded, skip loading directly
self.listView = List.create(cc.size(ls.w(self)-20, ls.h(self) - 80), ccui.ListViewDirection.vertical, 20, 0)
self.listView:setAnchorPoint(cc.p(0.5,0.5))
self.listView:setBounceEnabled(true)
self.listView:setDirection(ccui.ListViewDirection.horizontal) -- Set horizontal arrangement
ls.addChild2Pos(self, self.listView, cc.p(ls.w(self) / 2, ls.h(self) / 2-35))
self.isEnd = false; -- test , Judge that the bottom is called only once
self:refreshGoodList(self._index)
end
function LoginScene:refreshGoodList(_index)
-- self.listView:removeAllItems()
self.listView:setBackGroundColorType(1)
self.listView:setBackGroundColor(cc.c3b(0,123,0))
local function listViewEvent(sender, eventType)
-- The event type is click to end
print("eventType=",eventType)
if eventType == ccui.ListViewEventType.ONSELECTEDITEM_END then
print("select child index = ",sender:getCurSelectedIndex())
end
end
-- Set up ListView The monitoring event of
self.listView:addEventListener(listViewEvent)
-- Scroll event method callback
local function scrollViewEvent(sender, eventType)
if eventType == ccui.ScrollviewEventType.scrollToBottom then
elseif eventType == ccui.ScrollviewEventType.scrolling then
elseif eventType == ccui.ScrollviewEventType.bounceBottom then-- Scroll to the bottom
if self.isEnd == true then return end
print("qing qiu geng xin ")
self._index_len_init = self._index_len_end
for i =1, 10 do
table.insert(self._index , i)
end
self:refreshGoodList(self._index)
self.isEnd = true
elseif eventType == ccui.ScrollviewEventType.scrollToRight then -- Slide to the far right
if self.isEnd == true then return end
print("qing qiu geng xin ")
self._index_len_init = self._index_len_end
for i =1, 10 do
table.insert(self._index , i)
end
self:refreshGoodList(self._index)
self.isEnd = true
end
end
self._index_len_end=#_index
self.listView:addScrollViewEventListener(scrollViewEvent)
for i =self._index_len_init, self._index_len_end do
local labelContent = cc.Label:createWithTTF(_index[i], App.TTF_FONT, 40, cc.size(ls.w(self)-20, 0), cc.TEXT_ALIGNMENT_LEFT)
labelContent:setAnchorPoint(cc.p(0,1))
labelContent:setColor(cc.c3b(255,0,0))
local item = ccui.Layout:create()
item:setContentSize(cc.size(200,50))
ls.addChild2Pos(item, labelContent , cc.p(10,ls.h(item)+10 ))
self.listView:pushBackCustomItem(item)
end
end
边栏推荐
- [groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)
- 猿人学第一题
- Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
- Unity connects to the database
- Basic knowledge points of dictionary
- AutoCAD - feature matching
- XSS injection
- 【acwing】836. Merge sets
- Introduction to JVM principle and process
- LeetCode之單詞搜索(回溯法求解)
猜你喜欢
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
Chinese notes of unit particle system particle effect
Create a pyGame window with a blue background
Special information | finance, accounting, audit - 22.1.23
AutoCAD - stretching
2021-10-29
How to choose a panoramic camera that suits you?
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
【acwing】240. food chain
随机推荐
Research and investment forecast report of adamantane industry in China (2022 Edition)
The difference between bundle, chunk and module
China needle coke industry development research and investment value report (2022 Edition)
用 Jmeter 工具做个小型压力测试
Introduction to JVM principle and process
GameObject class and transform class of unity
54. 螺旋矩阵 & 59. 螺旋矩阵 II ●●
【acwing】240. food chain
PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low
質量體系建設之路的分分合合
2022 thinking of mathematical modeling C problem of American college students / analysis of 2022 American competition C problem
Function template
Minor spanning tree
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
[groovy] closure (closure call | closure default parameter it | code example)
Unity3d learning notes
[Business Research Report] Research Report on male consumption trends in other economic times -- with download link
Create a pyGame window with a blue background
Detailed explanation of the ranking of the best universities
Unity and database