In my layout xml, I use the following to define an EditText that can display currency.
<EditText
android:id="@+id/et1"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:imeOptions= "actionNext"
android:inputType="phone"
android:digits="0123456789.,$" >
However, this is not localized. I want to be able to use the symbol returned by NumberFormat.getCurrencyInstance().getCurrency().getSymbol();
in place of the $
in android:digits
.
What I don't know is how to set android:digits
from within my program.
Solved thanks to Agarwal. I just need to read the documentation more thoroughly.
For those interested, here is how I solved the original question. It is the complete implementation of a currency edit text that can handle multiple locales. Still may be some problems (Doesn't seem to display Japanese currency symbol correctly, and I can't get the keyboard I want (12_KEY)), but otherwise, some may find this helpful.
And the accompanying XML layout:
Yes you can check here
http://developer.android.com/reference/android/widget/EditText.html for almost every attribute there is equivalent method present.
Try this:
From Code:
But, it allows the user to include several "."
You can also do this for accepting on digits...