Maybe somebody has ideas on this, I haven't had much luck with responses in the forums here.
I'm trying to build a scrollable view, yet dynamically add/remove views as the user scrolls, similar to a sliding window.
The ScrollableView would potentially have hundreds of views as they scroll, and the idea is to only keep 5 or so views around, and add/remove views on demand. I'm trying to do this with the 'scroll' event.
This sounds nice, but I'm not having luck, especially with removing views. Adding views works, if manually set the "views" member of the ScrollableView.
However, I can't dynamically call addView(), as this messes up the position and the scrollview jumps to the newly added view, even though it shouldn't.
I also can't remove views. Removing a view object from the array (e.g. using JS shift()) will crash the app eventually, and calling removeView() also yields odd behavior - and it plain doesn't work - it's not being removed.
Any ideas would be welcome, the kitchen sink only has a fairly simplified example of this.
At this point I am resigning myself to just keep adding views and crossing my fingers, I'm not sure how to even determine the memory consumption.
This is certainly a bug on android. See this Q&A / ticket. I am not sure what the status is for iOS.
Thus, to insert a view in the middle of a set of scrollable views, the workaround is to remove views in the order that they were added, add the new view, and add back the other views.
To jump to a specific view, you can use the scrollToView() method.
Thanks, I know about the scrollToView() method.
I'm not really trying to add something into the middle, but instead at the beginning. As such, if I have a dataset of say 200 objects (say images, views) that I want to scroll over, then I could just have some sort of sliding window where I push/pop views from the start/end as the user scrolls.
This way I wouldn't have to pre-load the entire dataset. I guess this is turning into a feature request now, but I'm not sure if I'm missing something and this is already possible.