我正在尝试将String.ValueOf舍入到最接近的整数。知道如何将String.valueOf(result)变为最接近的整数。
public void onClick(View v) {
double result =0;
double result1 =0;
double a = Double.parseDouble(weightEntered.getText().toString().trim());
double b = 2.2;
if(v == button_convert)
{
if(lbs_kg.isChecked() == true) {
result = (a / b);
String str = String.valueOf(result);
t1.setText(str);
}
答案 0 :(得分:2)
String str = String.valueOf(Math.round(result));