I am using Customlistview for the first time and wish to show a list of checkboxes.
Initially all list items are unchecked.
Each list item has the checked value saved to a map and eventually a file.
What I want to do is on subsequent creations of the Customlistview is set each list item's checkbox as it was saved last time it was shown.
I have tried to set the checked box by modifying the example code snippet
I hit a problem that when I set
chk.checked=Checked
It fires the chk_CheckedChanged sub.
it thows an error in the class as there is no parent because nothing has been clicked.
Is there a way around this?
Can the checkbox be set in this way?
p.s. Running the CustomListView example code on its own activity works correctly - chk_CheckedChanged subroutine does not fire.
Kintara
Initially all list items are unchecked.
Each list item has the checked value saved to a map and eventually a file.
What I want to do is on subsequent creations of the Customlistview is set each list item's checkbox as it was saved last time it was shown.
I have tried to set the checked box by modifying the example code snippet
B4X:
Sub
For i = 1 To 10
clv3.Add(CreateListItem("Item #" & i, True, clv3.AsView.Width, 50dip), 50dip, "Item #" & i)
Next
end sub
Sub CreateListItem2(Text As String, Checked as Boolean, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
Dim chk As CheckBox
chk.Initialize("chk")
chk.checked=Checked
p.AddView(chk, 380dip, 2dip, 50dip, Height - 4dip) 'view #0
Return p
End Sub
I hit a problem that when I set
chk.checked=Checked
It fires the chk_CheckedChanged sub.
it thows an error in the class as there is no parent because nothing has been clicked.
Is there a way around this?
Can the checkbox be set in this way?
p.s. Running the CustomListView example code on its own activity works correctly - chk_CheckedChanged subroutine does not fire.
Kintara
Last edited: