尝试在Android中将字符串转换为整数时出现NumberFormatException

时间:2019-06-10 09:25:26

标签: android

我正在尝试绑定来自API响应的数据。数量项目的出现就像一个字符串值“ 1.000” 。我想将其转换为整数并将其设置为TextView。因为数量不能为十进制值。我做到了

 int qty = Integer.parseInt(item.getOrderedQty());

 outstandingItemRowHolder.orderedQuantity.setText(qty+"");

但是它使应用程序崩溃并给出

的异常
java.lang.NumberFormatException: For input string: "1.000"
    at java.lang.Integer.parseInt(Integer.java:608)
    at java.lang.Integer.parseInt(Integer.java:643)

0 个答案:

没有答案
相关问题