Cannot call this method while RecyclerView is computing a layout or scrolling when try remove item from recyclerview
Below answer worked for me
This is just workaround
for the problem.
This usually occurs when you are calling notifyDataSetChanged()
on the background thread
. So just move notify to UI thread
dialeecyclerView.post(new Runnable()
{
@Override
public void run() {
myadapter.notifyDataSetChanged();
}
});
You use your
RecyclerView
instance and inside the post method a new Runnable added to the message queue. The runnable will be run on the user interface thread. This is a limit for Android to access theUI
thread from background (e.g. inside a method which will be run in a background thread). for more you run it onUI
thread if you needed.
For more you can run it on UI
thread, if you needed
runOnUiThread(new Runnable(){
public void run() {
// UI code goes here
}
});
This is useful when select All checkbox on click of top checkbox in recyclerview.
recyclerview.post(new Runnable()
{
@Override
public void run() {
myadapter.notifyDataSetChanged();
}
});
If you are tyring to notify recylew item then use isComputingLayout method:
if (!mRecyclerView.isComputingLayout())
{
// add your code here
}