8

Possible Duplicate:
Better way to Format Currency Input editText?

The problem is simple and basic... but I can't find a decent way of handling it. I have some fields with money values and I need to have both the currency symbol and the decimal value. Here is what I am talking about:

enter image description here

The user will input the value: 1 and then . and then 8 and then 0. The EUR symbol I want it to be visible all time.

What's the best way of achieving this ?

Community
  • 1
  • 1
Alin
  • 14,809
  • 40
  • 129
  • 218
  • As the answers say, you can probably accomplish this with a `TextWatcher`, but wouldn't it be easier to just move the symbol to the right of the `EditText` (outside it). – Jave Apr 24 '12 at 12:40
  • @Alin: So is it necessary for it to constantly show the Euro symbol? Personally, I'd just format after the user enters the amount (i.e. they enter 1.8, exit the EditText, it shows €1.80) – Kevin Coppock Apr 24 '12 at 13:06
  • ... and sometimes the currency sign is left of the number (dollars, pound), sometimes right of the number (Euro) – Frischling Nov 25 '21 at 08:38

2 Answers2

8

Try to use a textwatcher :D

http://developer.android.com/reference/android/text/TextWatcher.html

Better way to Format Currency Input editText?

With this u can format the incoming String before its display, so u can easily append a "€" and other stuff

Community
  • 1
  • 1
Thkru
  • 4,218
  • 2
  • 18
  • 37
1

You can achieve that by using a TextWatcher. Look at this Question which is quite similar to yours.

Community
  • 1
  • 1
Renard
  • 6,909
  • 2
  • 27
  • 23