我試圖在編輯文本中顯示錯誤圖標,並在代碼下面嘗試,但它並未在所有編輯文本字段中顯示錯誤圖標。錯誤圖標未在所有EditText字段中顯示
txtEmailAddess.requestFocus();
txtEmailAddess.setError(result.getEmailAddressMessage());
txtPassword.requestFocus();
txtPassword.setError(result.getPasswordMessage());
在下面的截圖中,它僅顯示密碼字段中的錯誤圖標。但不在電子郵件地址字段。有可能在兩個領域都顯示紅色的圓形圖標嗎?
以XML 代碼
<android.support.design.widget.TextInputLayout
android:id="@+id/lblEmailAddress_login"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/txtEmailAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_email"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lblPassword_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lblEmailAddress_login">
<EditText
android:id="@+id/txtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:hint="@string/hint_password"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
請添加更多關於您調用的佈局和方法的代碼「..setError(..)」 –
你可以用xml檢查嗎? – g7pro
添加了代碼。請讓我知道如果你需要更多的細節。 – Pankaj