diff --git a/helper/src/main/java/recyclerview/helper/SelectableHelper.java b/helper/src/main/java/recyclerview/helper/SelectableHelper.java index 53f89c8..65365a5 100644 --- a/helper/src/main/java/recyclerview/helper/SelectableHelper.java +++ b/helper/src/main/java/recyclerview/helper/SelectableHelper.java @@ -142,12 +142,9 @@ public void setSelectMode(SelectMode mode) { /** * 清除所所列表项的选中状态。 */ - @SuppressWarnings("WhileLoopReplaceableByForEach") public void clearSelected() { - Iterator iterator = mSelectedPositions.iterator(); - while (iterator.hasNext()) { - // 不能使用 for 循环,因为该方法会会删除列表中的元素 - deselect(iterator.next()); + for (int position : new ArrayList<>(mSelectedPositions)) { + deselect(position); } notifySelectCountChanged(); }