Android Question Customlistview Snap to Card

Discussion in 'Android Questions' started by DawningTruth, Feb 20, 2019.

  1. DawningTruth

    DawningTruth Active Member Licensed User


    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?

  2. Erel

    Erel Administrator Staff Member Licensed User

    This is a mistake. Use the library.

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

    Sub CLV1_ScrollChanged (Offset As Int)
       ScrollIndex = ScrollIndex + 
    Dim MyIndex As Int = ScrollIndex 'ScrollIndex as a global int variable
    If ScrollIndex <> MyIndex Then Return
    Dim VisibleIndex As Int = CLV1.FirstVisibleIndex
    Dim RawItem As CLVItem = CLV1.GetRawListItem(VisibleIndex)
    Dim CurrentOffset As Int =
    If CurrentOffset - RawItem.Offset > RawItem.Size / 2 Then
           CLV1.ScrollToItem(VisibleIndex + 
    End If
    End Sub
    DawningTruth likes this.
  3. DawningTruth

    DawningTruth Active Member Licensed User

    Thx Erel.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice