我得到 mGTotal 的价值,例如:179.257856
但现在我只想显示小数点后的两位数字,例如:179.25
@Override
protected void onResume()
{
super.onResume();
if (Constants.mItem_Detail.size() == 0)
{
return;
}
Double mGTotal = Double.parseDouble(Constants.mItem_Detail.get(0).get(SingleProductActivity.KEY_TOTAL));
for (int i = 1; i < Constants.mItem_Detail.size(); i++)
{
mGTotal = mGTotal + Double.parseDouble(Constants.mItem_Detail.get(i).get(SingleProductActivity.KEY_TOTAL));
}
mGrandTotal = String.valueOf(mGTotal);
mTxtViewGrandTotal.setText(mGrandTotal);
myTextVeiwGrandTotal.setText(mGrandTotal);
mTotal = String.valueOf(Constants.mItem_Detail.size());
mItems.setText(mTotal);
}
}