Android Question Automatic Scroll Listview to certain position

cirollo

Active Member
Licensed User
Hi guys!

I have 50 items in the listview and click the item nr.35 (it could be the 2nd or 3rd or 4th record on the screen).
I made my modifications as in the item_click event, then I would like the selected item to be in the same position as before, not at the first position (is already done this way)....

so, on the screen:

xxxxx
xxxxx
xxxxx <--- my item
xxxxx
.......
xxxxx

after item_click event (and associated calculations), I must still have:

xxxxx
xxxxx
xxxxx <--- my item
xxxxx
.......
xxxxx

and not....

xxxxx <--- my item
xxxxx
.......
xxxxx


is possible?
 

Tyler

Member
Licensed User
Sorry, I should have elaborated. Not sure if this will work 100% but if he were to setselection to the index 2 above that one for example, would that not place the desired index at the correct spot?
 

DonManfred

Expert
Licensed User
to the index 2 above that one for example, would that not place the desired index at the correct spot?
no.
B4X:
lv.SetSelection(2)
will scroll the 3rd item into the first visible position of the listbox.

xxxxx <--- 3rd item
xxxxx
xxxxx
xxxxx
.......
xxxxx

SetSelection is good if you want for example a "autoscrolling" listview while it fills... See example.
 

Attachments

Last edited:

cirollo

Active Member
Licensed User
don manfred is right....

I need to know the index of the first visible record on the screen, so I can set accordingly.....
 
Top