Private Sub ShowPersons()
dim li as List = GetPersons()
clvPersons.Clear
dim iWidth as int = clvPersons.AsView.Width, iHeight as int = 60dip 'look in the created layout for .Top and .Height values of the views, to calculate the Item-Height that is needed!
For Each t As PersonType In li
clvPersons.Add(CreatePersonItem(t, iWidth, iHeight), t)
Next
End Sub
Private Sub CreatePersonItem(t as PersonType, width As Int, height As Int) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, width, height)
p.LoadLayout("viewItmPerson") 'Create a layout "viewItmPerson" in designer with Labels "lblItmName" and "lblItmAge"
lblItmName.Text = t.name
lblItmAge.Text = t.age
Return p
End Sub
Private Sub clvPersons_ItemClick (Index As Int, Value As Object) 'handle an item click event
dim t as PersonType = Value
'do something with the user choice ...
End Sub
Private Sub lblRemove_Click 'handle click events, if you have views (as labels or buttons) on an item
Dim iIndex As Int = clvPersons.GetItemFromView(Sender)
Dim t As PersonType = clvPersons.GetValue(iIndex)
'do something with the user choice ...
End Sub