I am having trouble in implementing databinding in a Dialog. Is it possible?
Below is my xml.
mBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.dialog_select, null, false);
setContentView(mBinding.getRoot());
SelectDialogBean data = new SelectDialogBean();
mBinding.setData(data);
It is possible to use databinding in a Dialog, first to get the binding working on your Dialog you should inflate it first and pass it to the setContentView like this.
DialogOlaBookingConfirmedBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout. dialog_ola_booking_confirmed, null, false);
setContentView(binding.getRoot());
Then you can pass the viewModel:
binding.setViewModel(new ViewModel(this, event.olaBooking));
And now you can see it working.