diff --git a/app/src/main/java/com/hippo/easyrecyclerview/EasyRecyclerView.java b/app/src/main/java/com/hippo/easyrecyclerview/EasyRecyclerView.java index 081644cb5..c8f905338 100644 --- a/app/src/main/java/com/hippo/easyrecyclerview/EasyRecyclerView.java +++ b/app/src/main/java/com/hippo/easyrecyclerview/EasyRecyclerView.java @@ -119,7 +119,7 @@ public class EasyRecyclerView extends ScrollLessRecyclerView { */ private LongSparseArray mCheckedIdStates; - private Adapter mAdapter; + private Adapter mAdapter; public EasyRecyclerView(Context context) { super(context); @@ -161,6 +161,18 @@ public class EasyRecyclerView extends ScrollLessRecyclerView { } } + @Override + public void onChildAttachedToWindow(@NonNull View child) { + super.onChildAttachedToWindow(child); + + if (mCheckStates != null) { + int position = getChildAdapterPosition(child); + if (position >= 0) { + setViewChecked(child, mCheckStates.get(position)); + } + } + } + /** * Returns the number of items currently selected. This will only be valid * if the choice mode is not {@link #CHOICE_MODE_NONE} (default).