How to get Edittext value with databinding?
When you instantiate an ObservableField, the default value is null
. When the EditText
modifies the value (even if empty), it will be set to a non-null value. However, until then, it is null.
It is easy to fix this by giving your fields a non-null initial value:
public final ObservableField<String> email = new ObservableField<>("");
public final ObservableField<String> password = new ObservableField<>("");