I create a static class named Box, and there I calculate the parameter double AverageWeight.
Then, in my MainActivity, I would like to print the result in a TextView, and show only two digit after decimal. How do I do that?
I've searched this question on Stack Overflow but I haven't found anything that referred to formatting Double class, and nothing I've tried worked.
//Convert the output from double to String
String avgWeight = Double.toString(Box.getAverageWeight());
//Set the String output to TextView
tv_resAvgWeight.setText(avgWeight);