Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText which accepts only a few characters

I need to implement an EditText on Android which accepts only a specific range of characters, which are: "S,A,Q,W,R,B,C,D,E,U".

like image 467
prabu S Avatar asked Mar 16 '16 04:03

prabu S


People also ask

What is EMS in EditText?

The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion.

What is the difference between an EditText and a TextView?

EditText is used for user input. TextView is used to display text and is not editable by the user. TextView can be updated programatically at any time.


1 Answers

What about using these two attributes in your EditText

android:maxLength="1"
android:digits = "SABCDEU"
like image 145
Shree Krishna Avatar answered Oct 03 '22 22:10

Shree Krishna