Home » Android » android – Simple EditText currency formatter

android – Simple EditText currency formatter

Posted by: admin June 15, 2020 Leave a comment

Questions:

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 ?

How to&Answers:

Try to use a textwatcher 😀

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

Answer:

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