开发者

Only allow strings within EditText

I want to only allow strings to be entered within an EdiText, at the moment the user c开发者_如何学编程an enter int and strings.

Is there easy way to do this.

Thanks


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜