Raj
Raj

Reputation: 693

Only allow strings within EditText

I want to only allow strings to be entered within an EdiText, at the moment the user can enter int and strings.

Is there easy way to do this.

Thanks

Upvotes: 0

Views: 988

Answers (1)

user432209
user432209

Reputation: 20167

The easiest way to limit what a user can place in an EditText is via XML and the property inputType. Check out the available values here. However, an integer is a character just like a letter and can be part of a string. So glancing at the list I don't see a built in method that won't accept an integer but will accept letters.

So what you will probably have to do is override a listener for the EditText and write your own method that will test for characters 0-9 and prevent them from being entered in.

Upvotes: 5

Related Questions