In Android, I am setting the text of a textview to be the answer to a calculation which is a double data type.
When the double value has a value of 5, the textview receives the string: 5.0.
Code:
double result = number1/number2;
String finalresult = new Double(result).toString();
textView1.setText(finalresult);
How do I format the textView text so that it shows the double value in a consistent format?
In Android, assign a double to a textView:
Use Double.toString:
or you can use the NumberFormat:
To force for 3 units precision: