Android Question How to scroll/move xcustomlistview from Left to Right

omo

Active Member
Licensed User
Longtime User
With these codes below, i can move xcustomlistview from right to left, but how can the reverse be achieved? What i intend to achieve with this is to move with timer from right to left and then move back from left to right. After returning back to right, deactivate timer so that it can be moved freely manually as if no timer was used before. Below is the code that moves xcustomlistview from right to left

B4X:
Do While True
        '..vertical...xclv1.sv.ScrollViewOffsetY = xclv1.sv.ScrollViewOffsetY + 3dip

        xclv1.sv.ScrollViewOffsetX = xclv1.sv.ScrollViewOffsetX + 3dip
        Sleep(15)
        If xclv1.sv.ScrollViewOffsetX > 0 Then
            xclv1.sv.ScrollViewOffsetX = xclv1.sv.ScrollViewOffsetX - 1
      
        End If
    Loop
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
We are talking about a horizontal CLV, right?

Something like this untested code:
B4X:
Dim MovingLeft = 1, MovingRight = 2  As Int
Dim MaxOffset As Int = xclv1.sv.ScrollViewContentWidth - xclv1.sv.Width
Dim State As Int = MovingLeft
Dim delta As Int = 3dip
Do While True
 Dim offset As Int = xclv1.sv.ScrollViewOffsetX
 If State = MovingLeft Then
   offset = offset + delta
   If offset >= MaxOffset Then State = MovingRight
Else If State = MovingRight Then
  offset = offset - delta
  If offset <= 0 Then Exit
 Sleep(15)
Loop
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
We are talking about a horizontal CLV, right?

Something like this untested code:
B4X:
Dim MovingLeft = 1, MovingRight = 2  As Int
Dim MaxOffset As Int = xclv1.sv.ScrollViewContentWidth - xclv1.sv.Width
Dim State As Int = MovingLeft
Dim delta As Int = 3dip
Do While True
 Dim offset As Int = xclv1.sv.ScrollViewOffsetX
 If State = MovingLeft Then
   offset = offset + delta
   If offset >= MaxOffset Then State = MovingRight
Else If State = MovingRight Then
  offset = offset - delta
  If offset <= 0 Then Exit
 Sleep(15)
Loop
I tried this code under the timer by first un-commenting the one in #1 (after first closing with end if error), it freezes everything; nothing moves. I later moved it out of timer, it still freezes. It neither moves to left nor right while other controls stop responding. I tried to see if i could debug it to work, but wasn't successful.
 
Upvote 0
Top