Android RecyclerView : notifyDataSetChanged() IllegalStateException

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

    simply use isPressed() method of CompoundButton in onCheckedChanged(CompoundButton compoundButton, boolean isChecked)
    e.g

    public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {   
                          ... //your functionality    
                                if(compoundButton.isPressed()){
                                    notifyDataSetChanged();
                                }
                            }  });
    

提交回复
热议问题