1

密码字段部分的惊叹号:Android的 - 如何删除SETERROR()我的XML代码

<android.support.percent.PercentRelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
... 

    <android.support.design.widget.TextInputLayout 
     android:layout_below="@+id/uname_ly" 
     android:id="@+id/text_input_layout_passwd" 
     app:layout_widthPercent="70%" 
     android:layout_centerHorizontal="true" 
     app:layout_heightPercent="10%" 
     app:layout_marginTopPercent="0%" 
     app:layout_marginBottomPercent="0%" 
     android:adjustViewBounds="true" 
     android:textColorHint="@color/editTextHintColor" 
     app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout" 
     > 

     <EditText 
      android:id="@+id/password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/nopasswd" 
      android:inputType="textPassword" 
      android:maxLines="1" 
      android:textColor="@color/editTextTextColor" /> 

    </android.support.design.widget.TextInputLayout> 
... 

如何我删除此叠加红色感叹号时调用SETERROR()? enter image description here

[更新样式]

<style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance"> 
    <item name="android:textColor">@color/editTextHintColor</item> 
</style> 
+1

见这一次它会帮助你http://stackoverflow.com/q/5218691/5773037 –

+1

这可能会帮助你http://stackoverflow.com/questions/14413575/how -to-write-style-to-error-text-of-edittext-in-android –

+1

在“TextInputLayout”而不是“EditText”上调用'setError()'。 –

回答

3

使用setError(CharSequence error, Drawable icon)方法。设置drawable为空:

editText.setError("Pls provide email", null); 
+0

感谢您拯救我的生命。 –