So I have login form, when user click login I will check the inputs.
First what I do, onlick of login button i call textinputlayout.seterrorenabled(false)
, then when API call is over and I have an error on my editttext i call textinputlayout.seterrorenabled(true)
, textinputlayout.seterror(message)
. Everything is all good, now I click on login again and repeat same process textinputlayout.seterrorenabled(false)
and then after API call is over textinputlayout.seterrorenabled(true)
, textinputlayout.seterror(message)
. However this time the message doesn't show up. What's the problem?
<android.support.design.widget.TextInputLayout
android:id="@+id/usernameField1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/usernameField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/user_name"
android:textColorHint="#808080"
android:paddingBottom="@dimen/tendp"
android:paddingLeft="@dimen/tendp"
android:paddingRight="@dimen/tendp"
android:paddingTop="@dimen/tendp"
android:textSize="@dimen/textSize" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/passwordField1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/passwordField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:textColorHint="#808080"
android:paddingBottom="@dimen/tendp"
android:inputType="textPassword"
android:paddingLeft="@dimen/tendp"
android:paddingRight="@dimen/tendp"
android:paddingTop="@dimen/tendp"
android:textSize="@dimen/textSize" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:background="?attr/selectableItemBackground"
android:text="@string/login"
android:visibility="gone"
android:textColor="@android:color/white"
android:textSize="@dimen/textSize" >
</Button>
final Button login = (Button) findViewById(R.id.login);
// login.setOnClickListener(new OnClickListener() {
login.setOnClickListener(here i set my textinputlayout to errorenabled false or seterror null // start an asynctask
here in asynctask onpostexecute i set the errorenabled(true) and set error( the message)