1
我得到價值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);
}
}