B4J Question [Workaround] How Sync two ListViews

Jorge M A

Well-Known Member
Licensed User
Rookie question.
I have two ListViews that I need to synchronize when the user clicks on an item, the second list will select the same index. So far I have no problem.
The problem is the visibility of the selected item. (or the position of the ScrollBar?)
How can I get both lists to show the item in the same location? (Easy way?)
Thanks a Lot!
 

Jorge M A

Well-Known Member
Licensed User
Yes, thank you, sir. I know that and using it.
But when I click on an Item, both scroll to the top of the list (FirstVisible Item).
My question is how to keep the same position in both when clicking, without moving it to the top of the list.
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Ok, my basic, solution based on Offset:

B4X:
Sub CustomListView2_ScrollChanged (Offset As Int)
    CustomListView1.sv.ScrollViewOffsetY=Offset
End Sub
Sub CustomListView1_ScrollChanged (Offset As Int)
    CustomListView2.sv.ScrollViewOffsetY=Offset
End Sub

Thanks!
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
Paste this inside clv 1 item click event
B4X:
if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
        CustomListView2.sv.ScrollViewOffsetY = CustomListView1.sv.ScrollViewOffsetY
End if

Paste this inside clv 2 item click event
B4X:
if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
        CustomListView1.sv.ScrollViewOffsetY = CustomListView2.sv.ScrollViewOffsetY
End if
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Paste this inside clv 1 item click event
B4X:
if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
        CustomListView2.sv.ScrollViewOffsetY = CustomListView1.sv.ScrollViewOffsetY
End if

Paste this inside clv 2 item click event
B4X:
if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
        CustomListView1.sv.ScrollViewOffsetY = CustomListView2.sv.ScrollViewOffsetY
End if
Thank You Man!
 
Upvote 0
Top