So yesterday I have finally found some time to try new DataBinding library. I have tried to use it with CursorAdapter but with no success.
As Androidguys written on
Based on Android developers video about databinding It looks like ItemBinding is set as tag for view (in their case it is passed inside ViewHolder) and retrieved later. Thats where I found idea to find binding inside views:
So the Solution is:
private class BookCursorAdapter extends CursorAdapter {
...
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
BookListItemBinding binding = BookListItemBinding.inflate(getLayoutInflater(), parent, false);
return binding.getRoot();
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
Book book = new Book(cursor);
BookListItemBinding binding = DataBindingUtil.getBinding(view);
binding.setBook(book);
}
}