0

I want from my EditText to accept only certain characters. I don`t want to filter them in listener, I want to set it in XML permanently.

I want to use only these characters: 0123456789abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWYZ

So I made string and add that to android:digits. I want to convert each lowercase letter to uppercase (I dont want to disable typing without shift just convert them)

I used android:textAllCaps="true" but this doesnt work.

martin1337
  • 2,384
  • 6
  • 38
  • 85

2 Answers2

3

You can do it in XML file

 android:digits="0123456789abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWYZ"

Possible duplicate: How to restrict the EditText to accept only alphanumeric characters

n3dx
  • 109
  • 6
2

Try this, This will help you for sure.

 editText.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
Prachi Singh
  • 564
  • 3
  • 8