I am using Android Data Binding framework I have suppose an EditText for login form with username as below
Fundamentally, you need a way to implement dependent fields. Error is dependent on the value of text. You want error value to get updated when text changes.
I have found two ways to achieve this:
EditText clears the error when user types. Data Binding expects that attribute's value is retained after invoking setter. So, it does not invoke the setter again if the value doesn't change. Hence, as soon as you type, if the computed error value is same, data binding will not call setter and hence, the error will disappear. This kind of makes error
attribute incompatible with Data Binding.
I prefer to use TextInputLayout provided by design library. It has a persistent error field and also looks better.