It’s also possible to use data binding within your RecyclerView Adapter.

Data model

public class Item {

private String name;

public String getName() { return name; }


XML Layout


android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:text=”@{}”/>

Adapter class

public class ListItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private Activity host; private List items;

public ListItemAdapter(Activity activity, List items) { = activity; this.items = items; }

@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // inflate layout and retrieve binding ListItemBinding binding = DataBindingUtil.inflate(host.getLayoutInflater(), R.layout.list_item, parent, false);

return new ItemViewHolder(binding);


@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { Item item = items.get(position);

ItemViewHolder itemViewHolder = (ItemViewHolder)holder;