双转换为字符串 [英] Converting double to string
本文介绍了双转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道是我还是什么,但我有一个问题,将double转换字符串。
I am not sure it is me or what but I am having a problem converting a double to string.
这是我的code:
double total = 44;
String total2 = Double.toString(total);
我是做错了还是我缺少一个步骤在这里。
Am i doing something wrong or am i missing a step here.
我得到错误 NumberFormatException异常
尝试转换这个当。
I get error NumberFormatException
when trying to convert this.
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;
}
});
我试图做到这一点在onTouchListener。生病后更code,基本上当用户触摸我想要的信息计算填土的EditText框的EditText框。
I am trying to do this in an onTouchListener. Ill post more code, basically when the user touches the edittext box i want the information to calculate a fill the edittext box.
推荐答案
双总= 44;
串共2 =将String.valueOf(总);
double total = 44;
String total2 = String.valueOf(total);
这将double转换为String
This will convert double to String
这篇关于双转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文