How to divide and load a ListView in multiple parts?

前端 未结 3 1214
陌清茗
陌清茗 2021-01-21 10:57

I am wondering how could i divide my ListView in parts and display only one part of it when user starts my app and display others when user press a Button called \"

3条回答
  •  无人共我
    2021-01-21 11:23

    well implementing a button is easy enough:

    in your onCreate, load your adapter with the 1st 50 items, then implement a button with an onClickListener that adds the next 50 etc.

    HOWEVER I think what you really want to do is lazy load your listview so as they scroll, it will load more items - that why you don't need to clutter the UI with an extra button.

    for this your listactivity should implement OnScrollListener

    here is an example of that: Android Endless List

提交回复
热议问题