Bug? re: [B4X] CLVSwipe - xCustomListView Swipe actions and pull to refresh not working.

kstainsb

Member
Licensed User
Longtime User
In B4i, the swipe down action to refresh does not work if there are only a few items in the CLV (no scrollchanged event raised?).

Easily reproduced by using the supplied example program, and reducing the list size from 100 to, say 5. No amount of swiping will cause the refresh.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This feature is based on the native bounce feature and the bounce feature is only active when the list can be scrolled. The workaround is to add an empty item at the bottom of the list.

You can use this code that is taken from XUI Views:
B4X:
Public Sub InternalAddStubToCLVIfNeeded(CustomListView1 As CustomListView, Color As Int)
    If CustomListView1.Size = 0 Then Return
    Dim LastItem As CLVItem = CustomListView1.GetRawListItem(CustomListView1.Size - 1)
    If LastItem.Offset + LastItem.Panel.Height < CustomListView1.AsView.Height Then
        'add a stub item
        Dim p As B4XView = xui.CreatePanel("stub")
        p.Color = Color
        Dim Height As Int = CustomListView1.AsView.Height - LastItem.Offset - LastItem.Panel.Height - 3dip
        If xui.IsB4J Then Height = Height + 5
        p.SetLayoutAnimated(0, 0, 0, CustomListView1.AsView.Width, Height)
        CustomListView1.Add(p, "")
        CustomListView1.sv.ScrollViewContentHeight = CustomListView1.sv.ScrollViewContentHeight - CustomListView1.DividerSize
    End If
End Sub
 
Top