2016-01-04 59 views

回答

0

TextInputLayout设置错误,你必须给该

例如,

  <LinearLayout 
       android:id="@+id/login_userbar" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 

       <android.support.design.widget.TextInputLayout 
        android:id="@+id/username_text_input_layout" 
        style="@style/TextLabel" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 

        <EditText 
         android:id="@+id/etUsername" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"/> 

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

检查this SO answer

+0

@Vinod Ranga不是你的问题解决? –

0

如果您尝试验证EditText字段,请尝试向您的EditText字段添加TextWatcher。

对于实例

mText.addTextChangedListener(new TextWatcher(){ 
    public void afterTextChanged(Editable edt){ 
     if(mText.getText().length() > 7){ 
     mText.setError("The input should be grater than 7 characters long"); 
     }else{ 
     mText.setError(null); 
     } 
    } 
} 

按照Android开发者文档,SETERROR(空)应该工作以清除错误。欲了解更多信息Click Here