android data binding with a custom view
In your Custom View, inflate layout however you normally would and provide a setter for the attribute you want to set: private MyCustomViewBinding mBinding; public MyCustomView(…) { … LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mBinding = MyCustomViewBinding.inflate(inflater); } public void setMyViewModel(MyViewModelObject obj) { mBinding.setMyViewModel(obj); } Then in the layout you use it in: <layout xmlns…> <data> … Read more