Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
expandable.Initialize(clvSidebar)
Try
For i = 1 To 5
Dim NumberOfItems As Int = Rnd(1, 20)
Dim p As B4XView = CreateItem(0xFF262626, "Item #" & i, NumberOfItems * 30dip + 30dip + 20dip, i - 1)
clvSidebar.Add(p, expandable.CreateValue(p, "some value: " & i))
For j = 1 To NumberOfItems
CustomListView1.Add(CreateScheduleList("subItem #" & j ,CustomListView1.AsView.Width, 30dip), j)
Next
Next
Catch
Log(LastException)
End Try
End Sub
Sub CreateItem(clr As Int, Title As String, ExpandedHeight As Int, ParentIndex As Int) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, clvSidebar.AsView.Width, ExpandedHeight)
p.LoadLayout("Layout2")
p.SetLayoutAnimated(0, 0, 0, p.Width, p.GetView(0).Height) 'resize it to the collapsed height
CustomListView1.AsView.Tag = ParentIndex
lblTitle.Text = Title
pnlTitle.Color = clr
pnlExpanded.Color = ShadeColor(clr)
Return p
End Sub
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
Dim clv As CustomListView = Sender
Dim ParentIndex As Int = clv.AsView.Tag
Dim ParentValue As String = expandable.GetValue(ParentIndex)
Log(ParentValue)
End Sub