一个很简单的问题,但是老实忘记:在循环列表中,如何处理数据刷新的问题
--Lua
self.mailItemScrollView.onRootCreated = function(holder)
local tran = holder.root:Find("Views")
--获取到数据的Index
local index = holder.ItemIndex + 1
--获取View的Index,这里是不能共用数据的Index,上面的Index是当前是第几个,但是View是复用的,应该是获取当前View实例的ID
获取
local insId = holder.root.gameObject:GetInstanceID()
---@type UIMailItemView
local cell = self._mailViewList[insId]
if cell == nil then
cell = mailView.New(tran, self)
self._mailViewList[index] = cell
end
local mailData = MailModule.mailDataList[index]
cell:Refresh(mailData, function()
this:MailClick(index)
end)
end