Android Question How to make CLV move smooth ?

Adamdam

Active Member
Licensed User
Longtime User
Dear All,
Greetings,
How to make CLV move smoothy as sliders ?
say for this example:
https://www.b4x.com/android/forum/threads/cards-list-with-customlistview.87720/#content

I made a timer and apply this command
B4X:
Sub Timer2_tick
    CLV1.ScrollToItem(itemNo)
    .
    .
End Sub

CLV jump even after written this command at
B4X:
Sub Activity_Create(FirstTime As Boolean)
    .
    .
    CLV1.AnimationDuration = 1000
    .
    .
End sub
What is the problem ? and how to solve to make CLV smoothy move like "automatic slider"

best regards
 

Adamdam

Active Member
Licensed User
Longtime User
CLV.ScrollToItem smoothly scrolls the list to the target item. I guess that your timer calls it again and again and breaks the smooth scrolling.
Many thanks Engr. Erel,
Yes, it scroll to target item but very fast, I need to make it slower.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Private Sub Button1_Click
    ScrollToItem(CustomListView1, 50, 2000)
End Sub

Private Sub ScrollToItem(CLV As CustomListView, Index As Int, Duration As Long)
    Dim offset As Int = CLV.GetRawListItem(Index).Offset
    Dim animator As JavaObject
    animator = animator.InitializeStatic("android.animation.ObjectAnimator").RunMethod("ofInt", Array(CLV.sv, "scrollY", Array As Int(offset)))
    animator.RunMethod("setDuration", Array(Duration))
    animator.RunMethod("start", Null)
End Sub
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
B4X:
Private Sub Button1_Click
    ScrollToItem(CustomListView1, 50, 2000)
End Sub

Private Sub ScrollToItem(CLV As CustomListView, Index As Int, Duration As Long)
    Dim offset As Int = CLV.GetRawListItem(Index).Offset
    Dim animator As JavaObject
    animator = animator.InitializeStatic("android.animation.ObjectAnimator").RunMethod("ofInt", Array(CLV.sv, "scrollY", Array As Int(offset)))
    animator.RunMethod("setDuration", Array(Duration))
    animator.RunMethod("start", Null)
End Sub
Really many thanks.
It work well, many thanks
 
Upvote 0
Top