My Recyclerview
list is as in the picture.
I want to update the child (example: just the ‘Like’ part) of a single item in my list. I did some research on the subject. I can update the whole item. However, what I need is to update one child of the item. I need code snippet on this. I’m new here, thanks in advance.
Advertisement
Answer
Let’s say you have a class named User and you are passing an ArrayList(that contains different User objects) to the RecyclerView Adapter.
JavaScript
x
public class User
{
.
private String name;
private int age;
//Getters, setters, etc ....
}
So for updating just the age, simply update that object present at that specific position in the list and then just refresh the RecyclerView.
JavaScript
.
users.get(position).setAge(xyz);
userAdapter.notifyItemChanged(position);
.