0
当我在RecyclerView中删除了一些项目,但它涉及到一个bug时,错误很难发生,但它有时会发生。有时该项目不会被删除,并仍然显示在recyclerView中,无法永久删除。以下是我的代码:recyclerView在循环bug中notifyItemRemoved?
//the positions is a collection,which collect my item positions that should be removed.
int realPosition;
int temp = 0;
for (int i = 0; i < positions.size(); i++) {
realPosition = positions.get(i) - temp;
getAdapter().remove(realPosition);
getAdapter().notifyItemRemoved(realPosition);
temp++;
}
我的英文很差,希望你能理解。谁能帮我?非常感谢你。
THX非常! (int i = positions.size() - 1:i> = 0; i - )' –
如果这有助于您考虑upvoting或将我的答案标记为答案 – bharath