androiddata-bindingandroid-databindingandroid-viewmodelandroid-binding-adapter

Changing the value of a string not updating the view in android databinding


I have an object which has a string variable that contains an image url in it. I have a data binding layout that accepts the instance of the previously mentioned object as data and binds the string containing image url to the image view. Until here it is working fine. The problem arises when i updates the string inside the object to a new url, the image view is not updating to the new image.


Solution

  • Use ObservableField<String> instead of a String

    https://developer.android.com/reference/android/databinding/ObservableField