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.
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.
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()});
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();
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.