Sub ImageViewSongList_Click
Activity.LoadLayout("SongList") ' This layout also contains a custom list view.
CSelections.Initialize(clvSongList)
CSelections.Mode = CSelections.MODE_MULTIPLE_ITEMS
' Make panel slide down out of sight.
'-----------------------------------------
PanelMenu.SetLayoutAnimated(300, 0, Activity.Height, Activity.Width, _
Activity.Height)
For intIndex = 0 To 2
' typValues will be used to store values into the Type elements for the list views.
'----------------------------------------------------------------------------------
Dim typValues As typListItemValues
' Adding items to the list view requires a Panel created in code.
'----------------------------------------------------------------
Dim p As B4XView = xui.CreatePanel("")
' This is the size for the panel and it will be animated.
'--------------------------------------------------------
p.SetLayoutAnimated(0, 0, 0, PanelSongList.Width, 200dip)
p.LoadLayout("SongListCard")
' Populate the views with values from the database.
'--------------------------------------------------
Select intIndex
Case 0
LabelSongTitle.Text = kvs.Get("Song1Title")
LabelSchedule.Text = kvs.Get("Song1Schedule")
If kvs.Get("Song1ScheduleIsActivated") Then
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-on-icon.png")
Else
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-off-icon.png")
End If
typValues.strSomeMoreText = "One"
Case 1
LabelSongTitle.Text = kvs.Get("Song2Title")
LabelSchedule.Text = kvs.Get("Song2Schedule")
If kvs.Get("Song2ScheduleIsActivated") Then
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-on-icon.png")
Else
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-off-icon.png")
End If
typValues.strSomeMoreText = "Two"
Case 2
LabelSongTitle.Text = kvs.Get("Song3Title")
LabelSchedule.Text = kvs.Get("Song3Schedule")
If kvs.Get("Song3ScheduleIsActivated") Then
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-on-icon.png")
Else
ImageViewSongIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-off-icon.png")
End If
typValues.strSomeMoreText = "Three"
End Select
typValues.LabelSongTitle = LabelSongTitle.Text
ImageViewPlayPauseSong.Tag = intIndex
' This is where the item row is added to the list view.
' Each list item has a set of Type structure elements associated with it.
'------------------------------------------------------------------------
clvSongList.Add(p,typValues)
Next
End Sub