Shahbaz Ahmad
1 min readMar 19, 2019

--

mAdapter.notifyItemInserted(studentList.size() - 1);

Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.

java.lang.IllegalStateException: androidx.recyclerview.widget.RecyclerView

I have replaced this line with

mRecyclerView.post(new Runnable() {
public void run() {
mAdapter.notifyItemInserted(studentList.size() - 1);
}
});

and the problem is solved.

--

--