Sub Process_Globals
Dim tm As Timer
End Sub
Sub Globals
Private CustomList As CustomListView
Private CardView As CardView 'I believe in the designer LayoutCellItem
Dim STR As AHSwipeToRefreshMulti 'I believe in the designer LayoutMain
Private PanelListView As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("LayoutMain")
PanelListView.Initialize("")
CustomList.Initialize("","CustomList")
PanelListView.AddView(CustomList.AsView,0,0,100%x,100%y)
STR.AddView(PanelListView)
STR.SetColorScheme2(Array As Int (Colors.Red, Colors.Blue, Colors.Green, Colors.Cyan, Colors.Magenta, Colors.Yellow))
Dim l As List
l.Initialize
l.Add(CustomList.AsView)
STR.SwipeableChilden = l
CargaLista
End Sub
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
Activity.AddView(p, 0, 0, Width, Height)
p.LoadLayout("LayoutCellItem")
p.RemoveView
'label1 and button1 will point to the last added views.
Return p
End Sub
Sub CargaLista
For i = 1 To 100
CustomList.Add(CreateListItem($"Item #${i}"$, CustomList.AsView.Width, 100dip), 112dip, $"Item #${i}"$)
Next
End Sub
Sub STR_Refresh
Log("Refresh started")
CustomList.Clear
'Start the timer. Normally you will start your asynchronous job here
tm.Initialize("Timer", 5000)
tm.Enabled = True
'Disable the STR object so we can not start a new refresh process
STR.Enabled = True
End Sub
'The timer tick simulates the end of the refreshing process
Sub Timer_Tick
Log("Refresh stopped")
'Stop Timer and refresh the listview data
tm.Enabled = False
CargaLista
'Stop the spinning disc and enable the STR object again.
STR.Refreshing = False
STR.Enabled = True
End Sub
Sub CardView_Click
Dim index As Int = CustomList.GetItemFromView(Sender)
ToastMessageShow("Checked items: " & CustomList.GetValue(index), False)
End Sub