I am not sure it is me or what but I am having a problem converting a double to string.
(我不确定它是我还是什么,但我在将double转换为字符串时遇到问题。)
here is my code:
(这是我的代码:)
double total = 44;
String total2 = Double.toString(total);
Am i doing something wrong or am i missing a step here.
(我做错了什么,或者我错过了一步。)
I get error NumberFormatException
when trying to convert this.
(尝试转换它时,我收到错误NumberFormatException
。)
totalCost.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
try {
double priceG = Double.parseDouble(priceGal.getText().toString());
double valG = Double.parseDouble(volGal.toString());
double total = priceG * valG;
String tot = new Double(total).toString();
totalCost.setText(tot);
} catch(Exception e) {
Log.e("text", e.toString());
}
return false;
}
});
I am trying to do this in an onTouchListener.
(我试图在onTouchListener中执行此操作。)
Ill post more code, basically when the user touches the edittext box i want the information to calculate a fill the edittext box. (我发布更多代码,基本上当用户触摸edittext框时,我希望信息计算填充edittext框。)
ask by Brandon Wilson translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…