Android EditText value to integer

自古美人都是妖i 提交于 2019-12-01 09:04:32

问题


I am creating a mortgage calculator android program and I was trying to figure out how to get the EditText value (comes back as an Editable) to convert to an integer so I can use those integers in the calculation of the mortgage. I know that there is a toString() method. Would that be the way to go and then try to convert it from a String to an integer?


回答1:


Integer i = Integer.valueOf(String s);

You should also configure the EditText to only accept integer values.



来源:https://stackoverflow.com/questions/4197356/android-edittext-value-to-integer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!