Android Question Customlistview Snap to Card

DawningTruth

Active Member
Licensed User
Hi,

I'm trying to modify the CustomListView.bas module as follows:

1. I want it to snap to each panel. Like the way it snaps when executing a Jump to Item.
2. I want it to only be activated when a user swipes.

The behaviour could basically be described as swiping between cards/panels. Swipe left for previous item, swipe right for next item.

I have taken a look at the module, but unfortunately am still a bit too new at B4x to fully understand the implementation.

Can you please provide some pointers as to how this could be accomplished and which methods would have to be modified?

Thx
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm trying to modify the CustomListView.bas module as follows:
This is a mistake. Use the library.

You can handle the ScrollChanged event to do what you need.

B4X:
Sub CLV1_ScrollChanged (Offset As Int)
   ScrollIndex = ScrollIndex + 1
   Dim MyIndex As Int = ScrollIndex 'ScrollIndex as a global int variable
   Sleep(300)
   If ScrollIndex <> MyIndex Then Return
   Dim VisibleIndex As Int = CLV1.FirstVisibleIndex
   Dim RawItem As CLVItem = CLV1.GetRawListItem(VisibleIndex)
   Dim CurrentOffset As Int = CLV1.sv.ScrollViewOffsetY
   If CurrentOffset - RawItem.Offset > RawItem.Size / 2 Then
       CLV1.ScrollToItem(VisibleIndex + 1)
   Else
       CLV1.ScrollToItem(VisibleIndex)
   End If
End Sub
 
Upvote 0
Top