0

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)
Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
user3278732
  • 1,694
  • 10
  • 31
  • 67
  • please post some code here. – Gundu Bandgar Mar 26 '16 at 10:10
  • could be an issue of milliseconds. i call seterror("message1") then directly seterror("message2")..its taking message 1 and not message 2. – user3278732 Mar 26 '16 at 10:28
  • yes could be bug in android http://stackoverflow.com/questions/34242902/textinputlayout-seterror-leaves-empty-space-after-clearing-the-error my issue is having lot of space when its verified correct. another issue is error not being displayed after being verified and edited to wrong choice. – user3278732 Mar 26 '16 at 10:36

1 Answers1

-1

Do not use textinputlayout.seterrorenabled(true) or textinputlayout.seterrorenabled(true) just textinputlayout.seterror(message) if you want to display message or textinputlayout.seterror(null) if you dont

KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
  • doesnt work, first time it shows. second time it doesnt. – user3278732 Mar 26 '16 at 10:07
  • could be an issue of milliseconds. i call seterror("message1") then directly seterror("message2")..its taking message 1 and not message 2. – user3278732 Mar 26 '16 at 10:28
  • btw try after setting seterror(null), to seterror("fail") and see if it works. – user3278732 Mar 26 '16 at 10:31
  • 1
    yes could be bug in android http://stackoverflow.com/questions/34242902/textinputlayout-seterror-leaves-empty-space-after-clearing-the-error my issue is having lot of space when its verified correct. another issue is error not being displayed after being verified and edited to wrong choice. – user3278732 Mar 26 '16 at 10:36