Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private xui As XUI
Private swipe As CLVSwipe
Private lblPullToRefresh As B4XView
Private ProgressBar1 As B4XView
Private clv1 As CustomListView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("Page1")
swipe.Initialize(clv1, Me, "swipe")
swipe.ActionColors = CreateMap("Delete": xui.Color_Red, "Do Something Else": xui.Color_Green, _
"Action 1": xui.Color_Red, "Action 2": xui.Color_Blue, "Action 3": xui.Color_Yellow)
Dim PullToRefreshPanel As B4XView = xui.CreatePanel("")
PullToRefreshPanel.SetLayoutAnimated(0, 0, 0, 100%x, 70dip)
PullToRefreshPanel.LoadLayout("PullToRefresh")
swipe.PullToRefreshPanel = PullToRefreshPanel
NavControl.ShowPage(Page1)
fillclv
End Sub
Sub fillclv
clv1.AddTextItem("Row 1", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
clv1.AddTextItem("Row 2", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
clv1.AddTextItem("Row 3", swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
clv1.Add(clv1_CreateItem,swipe.CreateItemValue("", Array("Delete", "Duplizieren")))
clv1.Add(clv1_CreateItem,swipe.CreateItemValue("", Array("Delete", "Duplizieren")))
XUIViewsUtils.AddStubToCLVIfNeeded(clv1, Colors.White)
End Sub
Sub clv1_CreateItem() As B4XView
Dim varPanel As B4XView = xui.CreatePanel(""), varColor As Int
varPanel.LoadLayout("line")
varPanel.Height = 80
Return varPanel
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Sub clv1_ItemClick (Index As Int, Value As Object)
swipe.CloseLastSwiped
End Sub
Sub clv1_ScrollChanged (Offset As Int)
If xui.IsB4i Then
swipe.ScrollChanged(Offset)
End If
swipe.CloseLastSwiped
End Sub
Sub swipe_ActionClicked (Index As Int, ActionText As String)
Log($"Action clicked: ${Index}, ${ActionText}"$)
If ActionText = "Delete" Then
clv1.RemoveAt(Index)
Else If ActionText = "Do Something Else" Then
Dim p As B4XView = clv1.GetPanel(Index)
Dim lbl As B4XView = p.GetView(0)
lbl.Text = "Done!!!"
End If
End Sub
Sub swipe_RefreshRequested
lblPullToRefresh.Text = "Loading..."
ProgressBar1.Visible = True
'example!!!
Sleep(3000)
clv1.Clear
fillclv
swipe.RefreshCompleted '<-- call to exit refresh mode
lblPullToRefresh.Text = "Pull to refresh"
ProgressBar1.Visible = False
End Sub