Skip to content
Advertisement

Update recycler view when a item is deleted on onBindViewHolder listener

I’m having a problem, that maybe we can solve it and help the community. I have made an Adapter for my RecyclerView and I have created a listener for the constraint layout in order to remove one element of the list. As you can see in the code the delete message works well but I don’t know how to update the RecyclerView from the AccountFragment (the one that’s using this adapter). Does anyone know how to notify that changes?

AccountFragment:

JavaScript

AccountCommentsAdapter:

JavaScript

UPDATE:

Solved by adding this method and then call it after userCommentsList.remove(position):

JavaScript

Advertisement

Answer

Inside the adapter you can use notifyDataSetChanged()

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement