If we want to limit the character input in an EditText , EditText in XML layout gives us android:maxLength to do this. But in java codes you might wonder why there isn’t any
setMaxLength(int length) function. The reason behind this is that when you want to restrict the EditText to accept certain value,
you have to filter them and this would be invoked by setFilters. To make our EditText to have a fixed size
we can use the following code.
EditText et = new EditText(this); int maxLength = 3;
InputFilter FilterArray = new InputFilter;
FilterArray = new InputFilter.LengthFilter(maxLength);