Wednesday, April 17, 2013

[android help] How to get rid of double decimal place


I'm trying to get rid of some of the decimal places in a double,I'v done it successfully on other part's of the app but i cant figure it out here. The double is coming in in a extra and i'm setting it to an edit text



double dryFree = sender.getExtras().getDouble("ResultFree");
else if (getIntent().hasExtra("ResultFree")) {
answer.setText( dryFree + "");


This is what i'v tried but app crashes



else if (getIntent().hasExtra("ResultFree")) {
answer.setText(String.format("%.2f", dryFree + ""));


Activity where number is coming from, I tried using string.format here to but getting errors, I know i'm using it wrong



total = (int) (a * b * c) / 0.424753;


.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...