B4J Question Customlistview disable autoscroll with InsertAt

nickt

Member
Hi

I want to disable the auto-scroll functionality

I have looked through the control and forum and cant find the answer

When adding 10, 20 ....100 items to the end of the list it seems to stay wherever it has been scrolled to...which is great and predictable for the user, however when adding x number of items to the start e.g. clv.InsertAt(0, pan,"") it scrolls to the first item inserted such that with 50 existing items and adding 10 new items (let's say insert numbers 50 to 59) the view will scroll automatically to show item number 50 as the last-visible-item (now item 9 in the list-view)....

How do I stop the auto scrolling and handle the list-item positioning myself. as it is important when I implement a version of lazy loading to deal with downwards scrolling for previous content where the newest item is at the bottom where users expect the screen to stay as it was and be unaware of any background processes

I looked for properties such as scroll-direction, orientation, reverse etc but couldn't find anything suitable.
 

nickt

Member
Hi Erel,

Thanks for the reply.

I already had InsertAnimationDuration at 0 and had tried firstvisibleindex and scrollto - neither of which solved the problem.

I have tried the offset but I seem to be doing something wrong as it still doesn't stay anywhere near the original position when using insert at the start...it is closer when i multiply the offset by 2 but still not right. A quick calculation shows that offset should reposition it to the original location. The logging shows that the initial positioning error when adding to the start is compounded every time with fractional values appearing when I read the initial offset position before the insert. Using a small number of inserts (10 or less) shows the relative movement better. Adding to the end works fine.

Any help would be appreciated
 

Attachments

  • scrollpos.zip
    61.6 KB · Views: 51
Upvote 0

nickt

Member
Thanks for the suggestion.

I tried it but it doesn't leave items in exactly the same position before new items are added. I modified the button to generate 5 at a time which made the movement more visible.

I also ran the example I sent with row heights set to 40 and added 50 records followed by inserting 50 at the head of the clv. No matter whether I used scrollto or offsetY to move 50 forward to the original (at 0) it moved approx halfway, then I doubled it to 100 and got out of bounds... 99 worked and positioned it a page short of where it should be... similarly increasing offsetY to the full height of all rows (or even above) resulted in the repositioning stopping approx 1 page (visible clv area) short.

I also tried inserting 1000 zero height rows and using replaceat from the 500 median. Visually the result was identical - including the repositioning falling short. It seems to me as if adding at the head of the clv puts am internal counter out. Maybe you could suggest a different control to try where I can control positioning and adding large numbers of objects

Thanks
 
Upvote 0
Top