'Updates a custom item at the specified index.
Public Sub UpdateAt(Index As Int, Pnl As Panel, ItemHeight As Int, Value As Object)
Dim removePanel, p As Panel
removePanel = panels.Get(Index)
items.RemoveAt(Index)
panels.RemoveAt(Index)
removePanel.RemoveView
Dim sd As StateListDrawable
sd.Initialize
sd.AddState(sd.State_Pressed, pressedDrawable)
sd.AddCatchAllState(Pnl.Background)
'create another panel to handle the click event
Dim p As Panel
p.Initialize("panel")
p.Background = sd
Dim cd As ColorDrawable
cd.Initialize(Colors.Transparent, 0)
Pnl.Background = cd
p.AddView(Pnl, 0, 0, sv.Width, ItemHeight)
p.Tag = Index
Dim top As Int
If Index = 0 Then
top = dividerHeight
Else
Dim previousPanel As Panel
previousPanel = panels.Get(Index - 1)
top = previousPanel.top + previousPanel.Height + dividerHeight
End If
items.InsertAt(Index, Value)
panels.InsertAt(Index, p)
sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
End Sub