MutableLiveData are not working in Databinding

Are you trying to use MutableLiveData instead of ObservableField? No errors, it just doesn’t work?😩

This happened to me last time. But you don’t have to struggle for an hour…

How to fix not working LiveData in Databinding

In your activity/fragment, when inflating an layout, add livecycleOwner to the databinding.

val dataBinding = DataBindingUtil.inflate<ViewDataBinding>(inflater,
        R.layout.activity_main, container, false)
dataBinding?.setVariable(BR.viewModel, viewModel)
// To enable DataBinding of LiveData
dataBinding?.setLifecycleOwner(activity as LifecycleOwner)