Sub Button1_Click
clv.Clear
For i=0 To Rnd(3, 10)
clv.Add(CreateclvItem(clv.AsView.Width, 40), i)
Next
End Sub
Private Sub CreateclvItem(Width As Double, Height As Double) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 10, 0, Width, Height)
p.LoadLayout("clvItem")
txt.Text = "text here"
cmb1.setItems(Array As String("item1", "item2", "item3", "item4", "item5"))
cmb1.cmbBox.Value="item3"
Return p
End Sub
Private Sub cmb1_SelectedIndexChanged (Index As Int)
Dim cmb As B4XComboBox = Sender
Dim cmbbox As B4XView = cmb.cmbBox
'try...catch... added to preventjava.lang.RuntimeException: Object should first be initialized (B4XView) occuring at
'Seems to occur when reloading the clv too quickly?
Try
Log(cmb.SelectedItem)
Dim s As String = clv.GetValue(clv.GetItemFromView(cmbbox)) <----error here
Log(s)
Catch
Log($"Error caught in cmb1_SelectedIndexChanged.
(Possibly occurs when quickly reloading the clv):
${LastException.Message}"$)
End Try
End Sub