Try creating your own InputLength filter. It will look something like this: (CustomLengthFilter.java) import android.text.InputFilter;
public class CustomLengthFilter extends InputFilter.LengthFilter { int maxLength; public CustomLengthFilter(int max) { super(max); maxLength = max; } public int get_MaxLength(){ return maxLength; } }
Then in your editText:
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(); }
source share