Edit text showing red underLine on the Text

2019-04-18 01:30发布

问题:

I am using a EditText to take date from the user. So when I am running my application on the default value that I have given it is underlining the text in red. XML Code

<EditText
      android:id="@+id/setDate"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="5dp"
      android:gravity="center_horizontal"
      android:text="dd/mm/yyyy" />

And in my Activity

date.setFocusableInTouchMode(false);

Why does it underline the text in red? Once the date is set then it is not showing me the red underline.

回答1:

I assume, that this is your spell check, so add:

android:inputType="textNoSuggestions"