I want to update data items in the RecyclerView after API call. I have used ObservableArrayList. After api call, I have used notifyChange()
in setter method. When I am passing the ObservableArrayList to the XML then I am getting error like this:
msg:Cannot find the setter for attribute 'bind:categories_list' with parameter type android.databinding.ObservableArrayList<T> on android.support.v7.widget.RecyclerView
XML is:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="list"
type="ObservableArrayList" />
<import type="android.databinding.ObservableArrayList" />
</data>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/white">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
bind:categories_list="@{list}" />
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</layout>