我正在尝试验证日期,并且正在使用“编辑文本”视图。我想设置一个错误消息,但是错误消息没有弹出,它只显示红色的错误符号。
这是我的“编辑文本”的XML代码。
<EditText
android:id="@+id/to_date"
android:hint="@string/_2020_02_24"
android:focusableInTouchMode="true"
android:cursorVisible="false"
android:focusable="false"
android:layout_weight="1.02"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
这是我的Java代码。
if(FromDate.compareTo(ToDate) < 0 || FromDate.compareTo(ToDate) == 0){
etToDate.setError(null);
}else{
etToDate.setError("Error");
etToDate.setFocusable(true);
etToDate.setFocusableInTouchMode(false);
}