Sub BuildTheSongListCustomListView
clvSongList.Clear
ButtonSongDetails.Visible = False
' Add 10 items to the list view.
'-------------------------------
For intIndex = 0 To 2
' typValues holds values from a custom type object that can be accessed from the values
' parameter of the ItemClick handler of this xCLV.
'--------------------------------------------------------------------------------------
Dim typValues As typSongsListItemValues
' 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.
' Doing the replace here will make sure unchecked days will not be displayed in the list.
'----------------------------------------------------------------------------------------
LabelSongTitle.Text = kvs.Get("Song" & (intIndex + 1) & "Title")
LabelSchedule.Text = LTrim(kvs.Get("Song" & (intIndex + 1) & "Schedule"))
LabelSchedule.Text = LabelSchedule.Text.Replace("100 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("200 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("300 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("400 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("500 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("600 ", "")
LabelSchedule.Text = LabelSchedule.Text.Replace("700 ", "")
LabelSchedule.Text = LTrim(LabelSchedule.Text)
LabelScheduleFromUntil.Text = _
kvs.Get("Song" & (intIndex + 1) & "ScheduleActiveFrom") & " To " & _
kvs.Get("Song" & (intIndex + 1) & "ScheduleActiveUntil")
If kvs.Get("Song" & (intIndex + 1) & "ScheduleIsActivated") Then
ImageViewSongScheduleIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-on-icon.png")
Else
ImageViewSongScheduleIsActivated.Bitmap = _
LoadBitmap(File.DirAssets, "light-off-icon.png")
End If
Select intIndex + 1
Case 1
If blnAsongIsPlaying And ServiceModule.blnSchedule1IsPlayingSong Then
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "pause-circle.png")
Else
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "play-circle.png")
End If
Case 2
If blnAsongIsPlaying And ServiceModule.blnSchedule2IsPlayingSong Then
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "pause-circle.png")
Else
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "play-circle.png")
End If
Case 3
If blnAsongIsPlaying And ServiceModule.blnSchedule3IsPlayingSong Then
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "pause-circle.png")
Else
ImageViewPlayPauseSong.Bitmap = _
LoadBitmap(File.DirAssets, "play-circle.png")
End If
End Select
' 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
If blnComingBackFromSongDetails Then
blnComingBackFromSongDetails = False
ButtonSongDetails.Visible = True
clvSongList.ScrollToItem(intCurrentSongSelected - 1)
cLvSelSongList.ItemClicked(intCurrentSongSelected - 1)
End If
End Sub