Skip to content Skip to sidebar Skip to footer

Indexoutofboundsexception Whenever I Want To Delete An Recyclerview Item

I manage to make a list with RecyclerView and now I want to delete a row by clicking on that row. But when I click on it, nothing happens and when I click again I get IndexOutOfBou

Solution 1:

Replace:

@Override
publicvoidonItemClick(View view, int position) {
    movieList.remove(position);
}

With:

@Override
publicvoidonItemClick(View view, int position) {
    movieList.remove(position);
    adapter.notifyItemRemoved(position);
}

Solution 2:

In the onClickListener try adding

    adapter.notifyDataSetChanged();

notifyDataSetChanged example

Post a Comment for "Indexoutofboundsexception Whenever I Want To Delete An Recyclerview Item"