1

This is what I am doing -->

//get entered texts from the edittexts,and convert to integers.
Integer value1 = Integer.parseInt(sand1.getText().toString());


//doing a calculation
Double calculatedValue1 = (9.5*value1);


//set the value to the textview, to display on screen.
result1.setText("$"+ calculatedValue1.toString());

result1 in the TextView looks like this now: ##.#

I need it to look like $##.##

Dawny33
  • 10,543
  • 21
  • 82
  • 134
Casey
  • 21
  • 1
  • 6

2 Answers2

1

Change your code to something like this :

/get entered texts from the edittexts,and convert to integers.
Integer value1 = Integer.parseInt(sand1.getText().toString());


//doing a calculation
Double calculatedValue1 = (9.5*value1);


//set the value to the textview, to display on screen.
result1.setText("$"+ String.format( "%.2f", calculatedValue1 ));
Arpit Ratan
  • 2,976
  • 1
  • 12
  • 20
0

Hello you could use this( Locale.US to format the number as USA standard and the %.2f for the decimal number) :

String.format(Locale.US, "%.2f", doubleValue);

AmirG
  • 615
  • 8
  • 18