How to clear highlighted items in the recyclerview?

后端 未结 2 1309
温柔的废话
温柔的废话 2020-12-04 03:25

I have implemented the recycler view multiple item selection by changing the background color of item when selected.When i remove those items from the model, items get remov

2条回答
  •  没有蜡笔的小新
    2020-12-04 03:45

    Your problem is in when (holder.is_selected.isChecked) {

    You should have the information if an item is checked on the ViewModel, not on the View and most definitely not in the ViewHolder.

    It should be something like if(residentItems.get(posistion).isSelected){ (Using when is overkill for binary cases)

提交回复
热议问题