So habe ich Login-Formular, wenn Benutzer klicken Sie auf Login Ich werde die Eingaben überprüfen.textinputlayout errorenabled und Fehler anzeigen
Erste, was ich tue, onlick von Login-Button aufrufen i textinputlayout.seterrorenabled(false)
, dann, wenn API-Aufruf ist vorbei, und ich habe einen Fehler auf meinem editttext i textinputlayout.seterrorenabled(true)
nennen, textinputlayout.seterror(message)
. Alles ist alles gut, jetzt klicke ich wieder auf Login und wiederhole den gleichen Prozess textinputlayout.seterrorenabled(false)
und dann nach API-Aufruf ist über textinputlayout.seterrorenabled(true)
, textinputlayout.seterror(message)
. Diesmal wird die Nachricht jedoch nicht angezeigt. Was ist das 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)
bitte hier einige Code schreiben. –
könnte ein Problem von Millisekunden sein. Ich rufe seterror ("message1") dann direkt seterror ("message2") auf. Es nimmt Nachricht 1 und nicht Nachricht 2. – user3278732
ja könnte Fehler sein in Android http://StackOverflow.com/Questions/34242902/Textinputlayout-Sterror- leaves-empty-space-nach-clearing-the-error Mein Problem ist viel Platz, wenn es verifiziert korrekt ist. Ein anderes Problem ist, dass der Fehler nicht angezeigt wird, nachdem er verifiziert und auf die falsche Auswahl eingestellt wurde. – user3278732