I have recycler view items with Checkbox component and implemented common "Check All" button. When I "uncheck" the button in list item, I want to "uncheck" common "Select All" Checkbox outside the recycler view.
I having issue in accessing the common "Select All" Checkbox in Adapter.
In my adapter class added below code,
private class UserViewHolder extends RecyclerView.ViewHolder {
public TextView title;
public CheckBox commonCheckbox, itemCheckbox;
public UserViewHolder(View view) {
super(view);
itemCheckbox=view.findViewById(R.id.itemcheckbox);
title=view.findViewById(R.id.title);
commonCheckbox = view.findViewById(R.id.commoncheckbox);
}
}
In onBindViewHolder, I implemented the following checked listener,
userViewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
userViewHolder.commonCheckbox.setChecked(false);
}
}
});
But, commonCheckbox showing null pointer exception. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire