Android: Fix java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item…..

Nhan Cao
1 min readMay 17, 2017

This error occur when the list in adapter clear why user scrolling which make position of item holder changing, lost ref between list and item on ui, error happen in next “notifyDataSetChanged” request.

Fix:

Review your update list method. If you do something like

mainList.clear();...mainList.add() or mainList.addAll()...notifyDataSetChanged();

===> Error occur

How to fix. Create new list object for buffer processing and assign again to main list after that

List res = new ArrayList();…..res.add();  //add item or modify list….mainList = res;notifyDataSetChanged();

--

--

Responses (6)