Reputation: 7029
Okay, so I have a ViewModel
with a getter getTitle()
that returns MutableLiveData<String>
.
<EditText
style="@style/Widget.EditText.FullWidth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_title"
android:inputType="text"
android:text="@={ viewModel.title }" />
This works fine at first: the EditText
contains the value of the MutableLiveData
when it first appears. However, if the value of this data is updated using MutableLiveData.setValue()
(such as by another EditText
, or from my code), then the value inside of the text box does not change. How do I fix this?
Upvotes: 7
Views: 5843
Reputation: 7029
This works properly in the new version of Android Studio, which supports binding to LiveData
objects properly.
Upvotes: 8