【发布时间】:2017-06-07 13:37:43
【问题描述】:
我正在尝试制作一个计算器,但是在我格式化文本后,我得到了 XX 中的输出,XX 插入了 XX.XX,这会导致程序在重用数字时崩溃。
我的代码是:
tempX = Double.parseDouble(xText.getText().toString());
//tempY = Double.parseDouble(yText.getText().toString());
tempA = Double.parseDouble(aText.getText().toString());
tempB = Double.parseDouble(bText.getText().toString());
tempY = tempA * tempX + tempB;
yText.setText(String.format("%.2f", tempY));
【问题讨论】:
标签: java android formatting