Android Endless list memory management

后端 未结 9 2075
温柔的废话
温柔的废话 2021-02-05 07:42

I\'m implementing an endless listview by loading more items to the arraylist in the onScrollStateChanged(...) method. If I\'m implementing this scheme for fetching more than 1 m

9条回答
  •  孤城傲影
    2021-02-05 08:14

    Tianwei's approach is the way to go.

    If the ListView is lazy loaded and since the ListView itself is recycling views it's best to keep only the visible list entries in memory. You basically do the same in the adapter the ListView does for the Views.

    If you'd keep all data in memory what would be the point of lazy loading the ListView anyway? Just load all data and skip the lazy loading part... Of course with the lazy loading approach that does load only the visible data (and maybe some more) you'd have to implement lazy loading at the bottom and the top of the list to make this work.

    Now since there's no information on the nature of the data (text, images) or the source (Internet, SQLite Db, text file...) I can't give you code (samples) how to implement this. If you elaborate on the data I can answer the question more accurately.

提交回复
热议问题