Sub ScrollCarols_CreateList
Dim List1 As List
Dim scList As List
scList.Initialize
Dim scS As Panel
scS.Initialize ("")
List1 = File.ReadList(File.DirAssets, "Carols.txt")
For i = 0 To List1.Size - 1
scList.Add(scS)
ScrollCarols.Panel.AddView (scList.Get(i),0,0,100%x,40dip)
Next
End Sub
Debugger says : You must call RemoveView () on the child's parent first.
But i add views programmatically , only ScrollView is in designer.
Thanks Erel. I will look at it. In this project i need panels , each contains Checkbox,Label and ImageView , and then each panel is added to ScrollView/CustomListview. The number of these panels must be generated depending number of strings in text file. How can i achieve this - ScrollView , CustomListView ?
In your code example you must Dim and Initialize the panels inside the For / Next loop.
B4X:
Sub ScrollCarols_CreateList
Dim List1 As List
Dim scList As List
scList.Initialize
List1 = File.ReadList(File.DirAssets, "Carols.txt")
For i = 0 To List1.Size - 1
Dim scS As Panel
scS.Initialize ("")
scList.Add(scS)
ScrollCarols.Panel.AddView (scS, 0, i * 40dip, 100%x, 40dip)
Next
End Sub
You must also increase the Top property of the panels i * 40dip insread of 0.
But anyway Erels suggestion is still the best one.