Android Question Scroll one position Customlistview

MarcoRome

Expert
Licensed User
Hi All.
I need to scroll one position only. If i scroll, positions are displayed ultil last, i need that when i run the scroll it simply stops at the next one, without shaking the others

I tried with this code, but dont work
B4X:
Sub clv_ScrollChanged (Offset As Int)
    Dim VisibleIndex As Int = clv.FirstVisibleIndex   
        clv.ScrollToItem(VisibleIndex + 1)
        Return
End Sub

Any solution ?
Thank you
Marco
 

MarcoRome

Expert
Licensed User
Resolverd:

B4X:
Sub clv_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 = clv.FirstVisibleIndex
    Dim RawItem As CLVItem = clv.GetRawListItem(VisibleIndex)
    Dim CurrentOffset As Int = clv.sv.ScrollViewOffsetY
    If CurrentOffset - RawItem.Offset > RawItem.Size / 2 Then
        clv.ScrollToItem(VisibleIndex + 1)
    Else
        clv.ScrollToItem(VisibleIndex)
    End If
        
End Sub
 
Upvote 0
Top