Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("SavedMessages")
LoadMessages
End Sub
Sub LoadMessages
Dim keys As List = PA_Messaging_Service.MessageStore.ListKeys
Dim CurrentTop As Int = 0
ScrollContainer.Panel.Height = 120dip * keys.Size
Dim i As Int = 0
For Each Key As String In keys
Dim RowPanel As Panel = MakeRowPanelForKey(Key,CurrentTop,i)
RowPanel.LoadLayout("MessageItemLayout")
ChangeTagOfEditButton(RowPanel, Key)
CurrentTop = CurrentTop + 122dip
Next
End Sub
Sub ChangeTagOfEditButton(RowPanel As Panel, Key As String)
For i = 0 To RowPanel.NumberOfViews
Dim v As View = RowPanel.GetView(i)
If v.Tag = "EditButton" Then
v.Tag = Key
End If
Next
End Sub
Sub MakeRowPanelForKey(Key As String, CurrentTop As String, Index As Int) As Panel
Dim RowPanel As Panel
RowPanel.Initialize("HandleRowClick")
ScrollContainer.Panel.AddView(RowPanel, 0, CurrentTop, 100%x, 120)
RowPanel.Height = 120dip
RowPanel.Width = 100%x
RowPanel.Tag = Key
If Index Mod 2 = 0 Then
RowPanel.Color = Colors.LightGray
Else
RowPanel.Color = Colors.Black
End If
Return RowPanel
End Sub