Android RecyclerView : notifyDataSetChanged() IllegalStateException

前端 未结 22 1855
天涯浪人
天涯浪人 2020-11-28 02:57

I\'m trying to update the items of a recycleview using notifyDataSetChanged().

This is my onBindViewHolder() method in the recycleview adapter.

@Over         


        
22条回答
  •  悲&欢浪女
    2020-11-28 03:40

    While item is being bound by the layout manager, it is very likely that you are setting the checked state of your checkbox, which is triggering the callback.

    Of course this is a guess because you did not publish the full stack trace.

    You cannot change adapter contents while RV is recalculating the layout. You can avoid it by not calling notifyDataSetChanged if item's checked state is equal to the value sent in the callback (which will be the case if calling checkbox.setChecked is triggering the callback).

提交回复
热议问题