#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private CustomListView1 As CustomListView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
For i = 0 To 100
CustomListView1.Add(createItem($"item ${i}"$,CustomListView1.AsView.Width,CustomListView1.AsView.Height/18),$"item ${i}"$)
Next
End Sub
Private Sub createItem (value As String, width As Float, height As Float) As B4XView
Dim p As B4XView = xui.CreatePanel("pnl")
p.Width = width
p.Height = height
p.Color = xui.Color_Green
p.Tag = value
Dim lbl As B4XView = createLabel("lbl")
lbl.Text = "I am a clickable Label"
lbl.TextColor = xui.Color_Black
lbl.TextSize = 14
lbl.SetTextAlignment("CENTER", "LEFT")
lbl.Tag = "Label: " & value
Dim btn As B4XView = createButton("btn")
btn.Text = "Click me"
btn.TextColor = xui.Color_Red
btn.TextSize = 14
btn.SetTextAlignment("CENTER", "CENTER")
btn.Tag = "Button: " & value
p.AddView(lbl,0,0,width*0.65,height)
p.AddView(btn,width*0.65,0,width*0.35,height)
Return p
End Sub
Private Sub btn_Click
Dim btn As B4XView = Sender
Log(btn.Tag.As(String))
End Sub
Private Sub lbl_MouseClicked (EventData As MouseEvent)
Dim lbl As B4XView = Sender
Log(lbl.Tag.As(String))
EventData.Consume
End Sub
Private Sub createLabel(eventName As String) As B4XView
Dim lbl As Label
lbl.Initialize(eventName)
Return lbl
End Sub
Private Sub createButton(eventName As String) As B4XView
Dim btn As Button
btn.Initialize(eventName)
Return btn
End Sub