Android Endless list memory management

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

    I couldn't find an exact number mentioned in the docs. However, the return types of all Adapter#getCount() (look at the subclasses) are ints.

    Therefore, we can strongly suspect you can add up to Integer.MAX_VALUE items into an adapter, which is 231-1 (over 2 billions). Adapters use Lists and Maps to store the data internally, which have the same limit.

    So you should not be worried about the limitations of the adapter rather than using too much memory. I suggest you to load 10-100 elements into the adapter and simply add more items as soon as the user reaches the bottom of the listview.

提交回复
热议问题