2011-08-22 4 views

답변

0

왜 InputFilter.LengthFilter의 길이를 "가져 오려고"합니까? 당신은 이미 그것을 설정할 때 어떤 길이인지 알 것입니다.

변경해야하는 경우 필터를 재설정하고 EditText보기에 적용하면됩니다. 다시 말하지만 길이 값이 무엇으로 설정되었는지 알 수 있습니다.

0

사용자 지정 InputLength 필터를 만들어보십시오. 다음과 같이 표시됩니다. (CustomLengthFilter.java) import android.text.InputFilter; 당신의 EDITTEXT에서 다음

public class CustomLengthFilter extends InputFilter.LengthFilter { 
    int maxLength; 

    public CustomLengthFilter(int max) { 
    super(max); 
    maxLength = max; 
    } 

    public int get_MaxLength(){ 
    return maxLength; 
    } 
} 

:

InputFilter[] inputFilterCollection = this.getFilters(); 
CustomLengthFilter mCustomLengthFilter = null; 
for(InputFilter eachInputFilter : inputFilterCollection){ 
    if(eachInputFilter instanceof CustomLengthFilter){ 
      mCustomLengthFilter = (CustomLengthFilter) eachInputFilter; 
    } 
} 
if(mCustomLengthFilter != null){ 
    int maxLength = mCustomLengthFilter.get_MaxLength(); 
} 
관련 문제