0
I am creating a simple application in android studio, where I make a division and present its result in an Edittext, however I would like to present only two decimal places, which is the best way to do this?
0
I am creating a simple application in android studio, where I make a division and present its result in an Edittext, however I would like to present only two decimal places, which is the best way to do this?
1
Use this code to format your decimals in float or double
float x = (float) 12.309989;
DecimalFormat df = new DecimalFormat("0.00");
editText.setText(df.format(x));
Browser other questions tagged java android
You are not signed in. Login or sign up in order to post.
You can use it like this:
String.format("%.2f", valor);
– gato
@cat I think you should post this as an answer :)
– Rosário Pereira Fernandes