Edit Text View setError() while focusable false

Viewed 111

I am trying to validate dates and am using Edit Text view. I want to set an Error message but The error Message isn't poping, it just shows the red Error symbol.
Here's my XML code for Edit Text.

<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"/>

and here's my java code.

if(FromDate.compareTo(ToDate) < 0 || FromDate.compareTo(ToDate) == 0){
            etToDate.setError(null);
        }else{
            etToDate.setError("Error");
            etToDate.setFocusable(true);
            etToDate.setFocusableInTouchMode(false);
        }

Error Image

0 Answers
Related