Android版的EditText值整数整数、Android、EditText

2023-09-06 06:01:57 作者:迷恋? 旧画面

我创建抵押计算器Android程序,我是想弄清楚如何获得的EditText值(回来为可编辑),以转换为整数,所以我可以在抵押贷款的计算中使用的整数。我知道,有一个toString()方法。请问这是否去,然后尝试将它从字符串转换为整数的方式?

解决方案

 整数i = Integer.valueOf(String s)将; 

您还应该配置的EditText只接受整数值。

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?

解决方案 Android EditText

Integer i = Integer.valueOf(String s);

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