开发者

How to ensure set type value in EditText to be only receive only int?

开发者 https://www.devze.com 2023-03-03 20:56 出处:网络
I want to calculate from 2 in开发者_StackOverflow社区put (2 EditText) which the value in EditText receive only int.

I want to calculate from 2 in开发者_StackOverflow社区put (2 EditText) which the value in EditText receive only int. How to code this?


Try adding android:numeric="decimal" to EditText


Use int myInt = Integer.parseInt("55"); Where 55 is the text that was entered in the edittext. If it is an integer in the text it will work; otherwise it will throw NumberFormatException if the string cannot be parsed as an integer value.

0

精彩评论

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

关注公众号