나는 그것이 나인지 확실하지 않지만 더블을 문자열로 변환하는 데 문제가 있습니다.
여기 내 코드가 있습니다 :
double total = 44;
String total2 = Double.toString(total);
내가 잘못하고 있거나 여기에 단계가 빠져 있습니까?
이것을 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;
}
});
onTouchListener 에서이 작업을 수행하려고합니다. 기본적으로 사용자가 편집 텍스트 상자를 터치하면 더 많은 코드를 게시하고 정보를 편집 텍스트 상자 채우기를 계산하기를 원합니다.