1

How can I call bindViewHolder on my recyclerView's adapter when my list of data changes?

I have 2 recyclerViews, selecting an item in one of them adds to the list of the second. Can I use a listener to check for change of data in my list or do I need to call bindViewHolder on my onClick function?

Here's how my onClickListener is implemented. selectedContacts is the list used in the second recyclerView.

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(rowLayout, viewGroup, false);
    return new ViewHolder(view, new ViewHolder.ViewHolderClickable() {
        @Override
        public void onClick(View contactView, int position) {
            selectedContacts.add(contacts.get(position));
        }
    });
}
Corey Wu
  • 1,209
  • 1
  • 22
  • 39
  • 1
    use https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyItemInserted(int) – pskink Dec 27 '14 at 20:22

0 Answers0