开发者

Editext validation for button click

开发者 https://www.devze.com 2023-02-17 20:38 出处:网络
I have an edittext and when the button is clicked 开发者_如何学编程it allows only Strings. I do this by using an if statement to show a dialog with this condition: (str.matches(\"[0-9]*\")

I have an edittext and when the button is clicked 开发者_如何学编程it allows only Strings.

I do this by using an if statement to show a dialog with this condition: (str.matches("[0-9]*")

but when I enter this ttttt12323 and press the button it allows string and int to go through.

I want to put validation for not allowing string and text together specifically only Strings.

Can this be done. Thanks


So you want to check if your input consists of characters only, right?

You could try something like (str.matches("[A-Za-z]*")

0

精彩评论

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