当前,我正在将数据绑定与mvvm一起用于xml中的设置错误
public final ObservableField<String> errorViewEmail = new
ObservableField<>();
以及验证集错误:
errorViewEmail.set("error in view");
和xml代码:
<android.support.design.widget.TextInputLayout
android:id="@+id/emailEtLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/gray"
app:errorEnabled="true"
app:error="@{viewModel.errorViewEmail}"
app:errorTextAppearance="@style/error_appearance"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout">
<android.support.design.widget.TextInputEditText
android:id="@+id/etEmail"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:maxLength="50"
android:textSize="@dimen/_18sp" />
</android.support.design.widget.TextInputLayout>
现在,当我设置错误时,错误设置仅一次,之后再次设置其不执行任何操作。我该如何使用它来验证电子邮件地址?还是可以使用MutableLiveData