Fix checked status

This commit is contained in:
tehcneko committed 2021-03-20 21:23:58 +08:00
1 parent c2286481fe
commit 311159d5fa
1 file changed
+13 -1
@@ -119,7 +119,7 @@ public class EasyRecyclerView extends ScrollLessRecyclerView {
*/
private LongSparseArray<Integer> 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).