'Main>>Sub Globals>>*** Add This ***
Private Button2 As Button
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
For i = 1 To 20
'*** Change this ***
'clv1.Add(CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i), CollapsedHeight, "")
clv1.Add(CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i, i ), CollapsedHeight, "")
Next
End Sub
'*** Change this ***
'Sub CreateItem(clr As Int, Title As String) As Panel
Sub CreateItem(clr As Int, Title As String, Index As Int) As Panel
Dim p As Panel
p.Initialize("")
Activity.AddView(p, 0, 0, 100%x, ExpandedHeight)
p.LoadLayout("Item")
'*** Add this ***
Button2.Tag=Index
p.RemoveView 'remove from parent
lblTitle.Text = Title
pnlTitle.Color = clr
pnlExpanded.Color = ShadeColor(clr)
p.Tag = False 'collapsed
Return p
End Sub
'Create this
Sub Button2_Click
Dim b As Button=Sender
Log("From button inside panel: " & b.Tag)
End Sub