There is a RecyclerView in my application. I need to implement a visual removal of the RecyclerView list item when I click on the button (The button is indicated in the list item markup). How to implement it?

  • I have already done the deletion from the database; I just need the item to be visually removed from the list. It is possible about removeItem (position) on in more detail? - Felay
  • adapter method for RecyclerView - notifyItemRemoved (position) will remove the item from the list at the specified position with animation. - pavlofff
  • However, if you use a database, I recommend to pay attention to modern solutions and conveniences appearing with it (the second part of the answer) - you only need to make changes to the database, the widget will update itself according to the current state of the database, it is very convenient. Here is a series of lessons on the topic and an example of an adapter - pavlofff

1 answer 1

In the adapter, add an interface that monitors the click on the delete icon. override the methods so that it would be possible to get a lincenter inside the activation / fragment

Then in the activation you set this lisenter and call by clicking on the icon delete adapter.notifyItemRemoved(viewHolder.getAdapterPosition());

  • Thank you. I figured it out. Works - Felay