Dim sd As StateListDrawable
sd.Initialize
sd.AddState(sd.State_Pressed, pressedDrawable)
sd.AddCatchAllState(Pnl.Background)
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
If Index = items.Size Then
items.Add(Value)
panels.Add(p)
Dim top As Int
If Index = 0 Then top = dividerHeight Else top = sv.Panel.Height
sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
Else
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
Dim p2 As Panel
For i = Index To panels.Size - 1
p2 = panels.Get(i)
p2.top = p2.top + ItemHeight + dividerHeight
p2.Tag = i + 1
Next
items.InsertAt(Index, Value)
panels.InsertAt(Index, p)
sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
End If
Dim lblDivider As Label
lblDivider.Initialize("")
lblDivider.Color = Colors.RGB(247,247,247)
p.AddView(lblDivider, 0,p.Height-1dip, 100%x, 1dip)
sv.Panel.Height = sv.Panel.Height + ItemHeight + dividerHeight
If items.Size = 1 Then sv.Panel.Height = sv.Panel.Height + dividerHeight
End Sub