-2

My question is related to this question. I am also looking for the same type of formatting but in reverse order.

Like if I press one it should print 1.00, then I press 2 and it will be 12.00. Then I press 3 it will be 123.00.

If I press (.) dot then it will be 123.00 only. And if now I press 9 then it will be 123.90, and if I then press 6 it will be 123.96 and will be till 2 decimal places only. Values after decimal will not increase after 2 and length of the value before the decimal point is unlimited. Pressing backspace deletes the last entered number.

Community
  • 1
  • 1
Suri
  • 61
  • 4
  • 1
    What have you tried ? Where do you struggle? Give some code so people can help you. – Marc-Andre May 17 '13 at 18:14
  • hi i tried some code can you look on this http://stackoverflow.com/questions/16675156/format-price-in-0-00-format-in-android-using-edittext – Suri May 21 '13 at 16:39

1 Answers1

1

You can use two int variables

  • one should store values before decimal
  • second should store values after decimal, also make sure value is not greater than 99 here.

after the input is complete join the two int variables into a string with a decimal place.

then parse it into a float variable.

Adam Lear
  • 38,111
  • 12
  • 81
  • 101
droidchef
  • 2,237
  • 1
  • 18
  • 34