My test app is based on this one. I duplicated two more CLVs. I want to use arrays to avoid duplicated codes. However I got "Object should be initialized first" error while calling pclv.initialize. Could someone kindly tell me what I did wrong?
TIA
TIA
Sub Globals:
Sub Globals
Private CustomListView1 As CustomListView
Private PCLV As PreoptimizedCLV
Private xui As XUI
Private Label1 As B4XView
Private words As List
Private NumberOfRealItems As Int
'added code:
Private CustomListView2 As CustomListView
Private CustomListView3 As CustomListView
Private PCLV2, PCLV3 As PreoptimizedCLV
Private const sectionCount As Int=3
Private CustomListViews() As CustomListView=Array As CustomListView(CustomListView1, CustomListView2,CustomListView3)
Private PCLVs() As PreoptimizedCLV=Array As PreoptimizedCLV(PCLV, PCLV2,PCLV3)
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
'Sleep(100)
words = Array("aaa", "bbb", "ccc", "ddd", "eee", "fff")
NumberOfRealItems = words.Size
For j=0 To sectionCount-1
PCLVs(j).Initialize(Me, "PCLV", CustomListViews(j)) '<=error: "Object should be initialized first"
PCLVs(j).ShowScrollBar = False
For i = 0 To 500
PCLVs(j).AddItem(49%x, xui.Color_White, words.Get(i Mod NumberOfRealItems))
Next
PCLV.Commit
Next
'Sleep(0)
'CustomListView1.JumpToItem(5000 - (5000 Mod NumberOfRealItems))
End Sub