Android Question How to detect accent characters in a text box?

Inman

Well-Known Member
Licensed User
In my app, some users enter their names using accent characters. Basically these are the characters you get when you long-press certain letters. Like when you do that on 'a', you can see some characters like 'a' with two dots on top and all. I want to check if a field contains one or more of such characters and show an error message.

I saw the code snippet that removes accent characters. What is the way to detect them?

 

Geezer

Active Member
Licensed User
If they're entering their names in an edittext you can set allowable characters and restrict the input.

If the names already exist, such as in a database, use the code snippet you referenced.
 

Inman

Well-Known Member
Licensed User
Thanks @Geezer . How do I set allowable characters for EditText? I can see InputType but it doesn't seem to have a type for English characters only.
 

Inman

Well-Known Member
Licensed User
While it is a good solution, unfortunately it won't work in my case. IME library works only with EditText and I am using DSFloatLabelEditText. I get an "incompatible types" error during compilation.

I am wondering if I should look at regex to check for such characters. Sadly I am not good with regex.
 
Top