0

I have a very simple code in XML:

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:text="@={viewModel.password}"
    android:enabled="@{viewModel.inputEnabled}">

Now when viewModel.inputEnabled is a MutableLiveData<Boolean> underneath, it simply doesn't work, edit is always enabled, regardless of value of inputEnabled. However, it takes only to change inputEnabled to an ObservableField<Boolean> (and switch setValue to set) such that it immediately starts working.

Why is that so? How can I make MutableLiveData work correctly?

Note, that this field is used in three places (to enable/disable form during processing).

Spook
  • 25,318
  • 18
  • 90
  • 167

1 Answers1

4

I ran in to same issue....make sure to call following in your activity/fragment:

binding.setLifecycleOwner(this)
John O'Reilly
  • 10,000
  • 4
  • 41
  • 63