Android RecyclerView : notifyDataSetChanged() IllegalStateException

前端 未结 22 1787
天涯浪人
天涯浪人 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:47

    I don't know well, but I also had same problem. I solved this by using onClickListner on checkbox

    viewHolder.mCheckBox.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                if (model.isCheckboxBoolean()) {
                    model.setCheckboxBoolean(false);
                    viewHolder.mCheckBox.setChecked(false);
                } else {
                    model.setCheckboxBoolean(true);
                    viewHolder.mCheckBox.setChecked(true);
                }
                notifyDataSetChanged();
            }
        });
    

    Try this, this may help!

提交回复
热议问题