I am using input filter:
int max_length;
max_length = 15;
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(max_length);
final EditText input = new EditText(getBaseContext());
input.setFilters(FilterArray);
alert_screen.setView(input);
It works, but I need to make max_length a conditional value. For example, if user inputs only digits, max_length will be equal to 15, but if user inputs some letter, max_length must be equal to 11.
You should use first
TextWatcher,Due to text change in your edittext ….http://developer.android.com/reference/android/text/TextWatcher.html
if user enter any letter in edittext condition of max is changed and if only digits also changed condition and put this condition in
onTextChanged(CharSequence s, int start, int before, int count).Just refrences is ::
http://thiranjith.wordpress.com/2010/12/12/how-to-specify-maximum-length-for-edittext-in-android/