How to print a double with two decimals in Android? [duplicate]

yourTextView.setText(String.format("Value of a: %.2f", a));

You can use a DecimalFormat, or String.format("%.2f", a);