Listview's checked items not there after scrolling

前端 未结 3 1345
挽巷
挽巷 2021-01-07 06:48

I have created a listview with textview and checkbox. However after scrolling the list down(or up) all the checked items in the list get unselected. How to make the checked

3条回答
  •  忘掉有多难
    2021-01-07 07:28

    ListView recycles the views every time it is scrolled. That's why the Check-boxes does not retain their states.

    To accomplish your task:

    • Store the checked items in an array.
    • When you click any checkbox in the listview, change the value of that particular item in the array.
    • Inside your getView method, check or uncheck the Check-boxes by reading the values from the array.

    That way your checkboxes will retain their states. I hope this is clear.

提交回复
热议问题