Android Endless list memory management

后端 未结 9 2053
温柔的废话
温柔的废话 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:07

    You should use paging and Load More button as a footer of ListView. For example:

    url = http://your_full_url.php?page=1

    let say you have 100 records in each page then very first time get all these 100 records of page 1, display those on ListView and cache them. Now scroll down your ListView and click on Load more button (Load More button should be set as footer of the ListView).

    When you click on Load More you will get next 100 records by calling

    url = http://your_full_url.php?page=2 and so on for

    url = http://your_full_url.php?page=3,

    url = http://your_full_url.php?page=4 etc...

    each time you will cache those records so that in case of connection loss you could show records available in cache.

提交回复
热议问题