I use customlistview to load tens of thousands of items with lazy load.
Load with empty pane:
When visible range changed, fill the pane
When I call clv.clear, the memory is not released.
Is this because the customlistview is a global variable?
The layout has two textareas.
Load with empty pane:
B4X:
Sub readWorkFile(filename As String,filesegments As List,fillUI As Boolean,root As String)
......
Dim segmentsList As List
segmentsList=sourceFileMap.Get(innerFilename)
filesegments.AddAll(segmentsList)
If fillUI Then
For Each bitext As List In segmentsList
createEmptyPane(bitext)
Next
End If
Next
End Sub
When visible range changed, fill the pane
B4X:
Public Sub fillPane(FirstIndex As Int, LastIndex As Int)
If segments.Size=0 Then
Return
End If
Dim ExtraSize As Int
ExtraSize=15
For i = Max(0,FirstIndex-ExtraSize*2) To Min(Main.editorLV.Size - 1,LastIndex+ExtraSize*2)
Dim segmentPane As Pane
segmentPane=Main.editorLV.GetPanel(i)
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
'visible+
segmentPane.Enabled=True
If segmentPane.NumberOfNodes = 0 Then
Dim bitext As List
bitext=segments.Get(i)
addTextAreaToSegmentPane(segmentPane,bitext.Get(0),bitext.Get(1))
End If
Else
'not visible
segmentPane.Enabled=False
If segmentPane.NumberOfNodes > 0 Then
segmentPane.RemoveAllNodes '<--- remove the layout
End If
End If
Next
End Sub
When I call clv.clear, the memory is not released.
Is this because the customlistview is a global variable?