People, I need help, I just can't fix a bug ... I have a RecycleView, the elements of which consist of TextView, ImageView, AnimChackBox. Pictures and text are loaded perfectly, but with AnimCheckBox problems. When you click on AnimCheckBox, the animation starts, while animation is running I quickly scroll the recycle view, new list items appear, on one of them the animation of the old AnimCheckBox ends and freezes, mBinding.setModel (item) updates the image and text, but the checkbox is not updated (remains in a frozen state). I did not find a solution to this problem ...

public class ViewHolder2 extends RecyclerView.ViewHolder { private final ItemListForPersonagesDialogBinding mBinding; public ViewHolder2( ItemListForPersonagesDialogBinding binding) { super(binding.getRoot()); mBinding=binding; } public void bind(final Dossier item) { // item Ρ…Ρ€Π°Π½ΠΈΡ‚ isSelected mBinding.setModel(item); mBinding.dialogCheckbox.setOnCheckedChangeListener(null); mBinding.setClick(new PersonagesListClick() { @Override public void onPersonageClick(View view) { if(item.isSelected()==true){ item.setSelected(false); mBinding.dialogCheckbox.setChecked(item.isSelected(),true);// (Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ , анимация) return; }else if(item.isSelected()==false){ item.setSelected(true); mBinding.dialogCheckbox.setChecked(item.isSelected(),true); // (Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ , анимация) return; } }); } } @BindingAdapter({"bind:android:checked"}) public static void upCB(AnimCheckBox view, boolean isC) { view.setChecked(isC,false); // (Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ , анимация) } 

enter image description here

  • You use some kind of library, if yes, you need to specify it in the question. Holder is intended for caching links to widgets, and not for binding to views. Where the adapter itself, the logic of his work is not clear. Look at this answer , perhaps the problem is in maintaining the state of the item - pavlofff
  • the adapter simply calls the bind method - NIk Dallas
  • "You can also not create a separate array, but create an additional field in your data model and write state saving there as well and restore the current state for output. Accordingly, you can return the collection of models themselves through the getter. This can be useful when required to link the data of the model itself and their sign of the check "- I did just that. The problem is in another ... - NIk Dallas

1 answer 1

It was necessary to still clear the animation for each item