If your Android app is crashing with error IllegalStateException “Cannot call this method while RecyclerView is computing a layout or scrolling”, you may try placing your notifyitemchanged inside a Runnable. Assuming you have a call to notifyItemChanged() inside onBindViewHolder() that is making your app crash with IllegalStateException, you may try something like this:
1 2 3 4 5 6 7 8 9 |
myRecyclerView.post(new Runnable() { @Override public void run() { myArrayList.remove(position); myArrayList.add(something); recyclerViewMainScreenHeader.getAdapter().<code>notifyItemChanged</code>(); } }); |