Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android editText max limit

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?

like image 555
Buda Gavril Avatar asked Mar 14 '11 13:03

Buda Gavril


People also ask

How do I limit text in EditText?

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.

How to set minimum and maximum input value in EditText in Android?

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" .


1 Answers

In XML itself for EditText give the following Attrib,

  android:maxLength="20"
like image 67
Ganapathy C Avatar answered Sep 28 '22 12:09

Ganapathy C