Android Question Loop Scroll in xCustomListView ?

cliv

Member
Licensed User
Longtime User
Can it be implement a Loop Scroll in xCustomListView?

Forward Loop:
... item#1 ---> item#2 ---> item#3 ---> item#4 ---> item#1 ---> item#2 ---> item#3 ---> item#4 ---> item#1 ---> ...

Back Loop:
... item#4 ---> item#3 ---> item#2 ---> item#1 ---> item#4 ---> item#3 ---> item#3 ---> item#1 ---> item#4 ---> ...
 

code:
Code: Copy
Sub Globals
   Private clv1 As CustomListView
   Private clv2 As CustomListView
   Private Label1 As B4XView
   Private CheckBox1 As B4XView
   Private xui As XUI
   Private jSV As JavaObject
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   For x = 1 To 3
       For i = 1 To 10
           clv1.AddTextItem("Item #" & i, "")
       Next
   Next
   Dim jSV As JavaObject = clv1.sv
   jSV.RunMethod("setVerticalScrollBarEnabled", Array(False))

End Sub

Sub clv1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
   Log(FirstIndex)
   Dim RealSize As Int = Round(clv1.Size / 3)
   If FirstIndex < RealSize Then
       StopScroll
       clv1.SetScrollViewOffset(clv1.GetScrollViewOffset + clv1.GetScrollViewContentSize /  3)
   else if FirstIndex >= RealSize * 2 Then
       StopScroll
       clv1.SetScrollViewOffset(clv1.GetScrollViewOffset - clv1.GetScrollViewContentSize /  3)
   End If
End Sub

Private Sub StopScroll
   jSV.RunMethod("smoothScrollBy", Array(0, 0))
End Sub

You will need to change the visibility of a few of the properties in the class from Private to Public.
 
Upvote 0
Back
Top