Allow only upper case letters in EditText

3

I know I can make the EditText screen always rotated, now I want to know if you can only allow capital letters at the moment the user types something.

    
asked by anonymous 30.10.2017 / 00:37

3 answers

2

Android has InputFilter for this, as you can see in official documentation . This is done by setting the filter using the setFilters() method of your EditText .

Ex:

editText.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
    
30.10.2017 / 12:33
2

If you put android:inputType="textCapCharacters" in the XML it will prioritize the uppercase letter, but the user may change depending on the device, so I suggest you tell him when to input the input data like this:

String algumaString = seuEdittext.getText().toString().toUpperCase();
    
30.10.2017 / 12:41
0

EditText has a property called setInputType that receives an int value of the InputType class where you can programmatically change the user's input while typing, but I think it is not possible to only limit characters because depending on the device keyboard it is possible for the user click on the symbol button and select a number for example.

    
31.01.2018 / 19:48