Set maxLength of EditText dynamically
At times you may want to set maxlength of EditText view dynamically.
You’ve to use setFilters method of EditText, as shown below.
EditText et = new EditText(this);
int maxLength = 3;
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(maxLength);
et.setFilters(FilterArray);
Hope it helps somebody…
Cheers 🙂
You may be also interested in