2017-03-12 6 views
7

오류 메시지를 표시하지 않고 텍스트 입력 레이아웃에서 오류를 설정할 수 있습니까? (다른 장소에서 이미 수행 중입니까?).TextInputLayout이 메시지없이 오류를 설정 했습니까?

textinputlayout.setError(""); 

은 불행하게도 작동하지 않습니다.

기본적으로 필요한 것은 textInputLayout을 사용하여 선 색상을 빨간색으로 변경하지만 프로그래밍 방식으로 처리해야합니다. 고마워요

+0

확인 [http://stackoverflow.com/questions/40838069/programmatically-changing-underline-color-of-editext] – RoHiT

+0

감사합니다.하지만 이미 시도 했으므로 텍스트가없는 텍스트 만 편집 할 수 있습니다. 입력 레이아웃 – oxcened

답변

0

오류가있는 레이아웃을 숨길 수 있습니다. 이처럼 :

textinputlayout.setError(""); 

if (textinputlayout.getChildCount() == 2) { 

     textinputlayout.getChildAt(1).setVisibility(View.GONE); 
} 
0

너무 늦지 않았습니다 희망하지만, setError 뒤의 코드는 다음과 같습니다

textinputlayout.setError(" ");

이 통과 이후 :

if (!mErrorEnabled) { 
    if (TextUtils.isEmpty(error)) { 
     // If error isn't enabled, and the error is empty, just return 
     return; 
    } 
} 

이 간단한 해결 방법이 될 것이다 의미 빈 오류 메시지 요청을 처리하는 것은 그리 잘 생각하지 못한 경우입니다.