Edittext.seterror Doesnt Show Error Text And Only Shows Icon
I have a simple validation in my app, here I am using four EdtiText.I am showing error when EditText loses focus but, the problem is on losing focus EditText only shows icon withou
Solution 1:
Use TextInputLayout
for material EditText
like :
<android.support.design.widget.TextInputLayout
android:id="@+id/input_application_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:minHeight="50dp"
android:theme="@style/MyTextInputLayout"
app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout">
<EditText
android:id="@+id/application_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_application_name"
android:imeOptions="actionNext"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
and in your Activity
TextInputLayout til = (TextInputLayout) findViewById(R.id.input_application_name);
EditText applicationNameEdt = (EditText) findViewById(R.id.application_name);
til.setErrorEnabled(true);
til.setError("You need to enter a name");
Post a Comment for "Edittext.seterror Doesnt Show Error Text And Only Shows Icon"