After I set the max character limit for an editText using InputFilter.LengthFilter, is there a way to make editText to react at onTextChanged after it reaches the maximum number of characters? if not, is there a simple way to set a max number of characters to an editText and still react at onTextChanged event?
This example demonstrate about How to limit text length of EditText in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
setFilters(new InputFilter[]{ new InputFilterMinMax("1", "12")}); This will allow user to enter values from 1 to 12 only. EDIT : Set your edittext with android:inputType="number" .
In XML itself for EditText give the following Attrib,
android:maxLength="20"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With