How to implement infinite scroll

How to implement infinite scroll
0

Hi,

How do you implement infinite scroll?
(i.e.: facebook …)
I would like to display big set of images (up to thousands).
Images are local or from network.

Sample code welcome :slight_smile:

Regards,
Chp

Tableview:
https://cocos2d-x.org/reference/native-cpp/V3.5/d2/d4b/classcocos2d_1_1extension_1_1_table_view.html

If you don’t know about Tableviews, they are also called lists/listviews in some other languages. Basically you create a cell/cells, and the tableview only draws on screen/reuses cells as you scroll and only updates data inside them for the specific cell index via a series of delegate methods.

On the infinite scroll part: if it is local data, then just use a sql (or other form of database) query to grab data from as part of your table delegate methods (Just make sure the query is efficient and using indexed data if there is a lot of data). If remote, keep a form of paginated lazy loading as the user gets close to the bottom of the scrollview. ie: start with say 50 cell data, and start lazy loading the next 50, as user gets towards bottom, push next 50 and start lazy loading next 50 from remote, and vica versa, keep some form of loading node view at the bottom if the data has not arrived yet and they have scrolled to the bottom.

2 Likes