:sign0104: I am new to B4A and need a little assistance. I am trying to populate a ScrollView with CheckBoxes, with strings contained in a List(Array). The List(Array) is properly formed, and I can Get the strings to display in the ScrollView. Let’s say that I have ten items in the array. The problem I am having, is that instead of displaying the ten array items sequentially in list form, all ten listed ScrollView items display the content of Array(0). Then all ten items in the list are overwritten with the content of Array(1), and so on, with the remaining items in the array, until the full ten travels of the loop. What is missing in my loop that causes this? Any help would be greatly appreciated. My code is below:
B4X:
Sub Populate_ScrollView()
Dim ScrollView1 As ScrollView
Dim lstChecks As List
Dim height As Int : height = 50dip
Dim pnl As Panel
ScrollView1.Initialize(0)
pnl = ScrollView1.Panel
Activity.AddView(ScrollView1, 0, 0, 100%x, 100%y)
lstChecks.Initialize
nbIndex = 0
For i = 1 To MsgNb
Dim chk As CheckBox
chk.Initialize("chkchng")
hSubjectItem = hSubjectList.Get(nbIndex) 'get the item
chk.Text = hSubjectItem
chk.tag = i
lstChecks.Add(chk)
Dim lbl1 As Label
lbl1.Initialize("")
hFromItem = hFromList.Get(nbIndex) 'get the item
lbl1.Text = hFromItem
lbl1.Gravity = Gravity.CENTER_VERTICAL
pnl.AddView(chk, 0, height * (i - 1), 120dip, height)
pnl.AddView(lbl1, 125dip, height * (i - 1), 120dip, height)
nbIndex = nbIndex + 1
Next
pnl.height = lstChecks.Size * height
End Sub
Last edited by a moderator: