当前位置:网站首页>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 (closure parameter binding | curry function | rcurry function | ncurry function | code example)
- Unity and database
- LeetCode之單詞搜索(回溯法求解)
- Séparation et combinaison de la construction du système qualité
- The difference between heap and stack
- Download the details and sequence of the original data access from the ENA database in EBI
- 775 Div.1 B. integral array mathematics
- xss注入
- AutoCAD - lengthening
- 【acwing】836. Merge sets
猜你喜欢

UE4/UE5 虚幻引擎,材质篇,纹理,Compression and Memory压缩和内存

AutoCAD - isometric annotation

669. Prune binary search tree ●●

How to choose a panoramic camera that suits you?

Solutions and answers for the 2021 Shenzhen cup

AutoCAD - lengthening

2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling

Recherche de mots pour leetcode (solution rétrospective)
![[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)](/img/36/c4206a95c007e41df628d99e06ba18.jpg)
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)

Panel panel of UI
随机推荐
[LeetCode] 整数反转【7】
3dsmax common commands
AutoCAD - workspace settings
质量体系建设之路的分分合合
Common database statements in unity
Error statuslogger log4j2 could not find a logging implementation
Redis 排查大 key 的4种方法,优化必备
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
Unity3d learning notes
django连接数据库报错,这是什么原因
LeetCode之单词搜索(回溯法求解)
3dsmax2018 common operations and some shortcut keys of editable polygons
UE 虚幻引擎,项目结构
计组笔记(1)——校验码、原补码乘除计算、浮点数计算
Flink集群配置
[groovy] closure (closure call | closure default parameter it | code example)
Download the details and sequence of the original data access from the ENA database in EBI
China needle coke industry development research and investment value report (2022 Edition)
Fluent objects and lists
UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化