I need to set a mask for a textview to convert its text to a specific style (Currency, my own though Like this: Rls ###,###,###,### ) but I need to be able to get it's raw text later on. What shall I do?
======================================================
say I will pass this string to the TextView: 2120000
It should be seen by user like : Rls 2,120,000
but the .getText method should return: 2120000
======================================================
the formatting code would be like this:
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator(',');
DecimalFormat decimalFormat = new DecimalFormat("Rls ###,###,###,###", symbols);
String prezzo = decimalFormat.format(Integer.parseInt(textTemp));
any help would be appreciated
Let's suppose you have a class
MyParser
:Now, let's have another class, called
MyTextView
:for convert long to rial format
You can use the same DecimalFormat object that you used to format the string to parse it back the other way:
You have to modify your edittext in each time you enter an input character. Try this code snippet
Correct way would be this: To create a custom TextView as a Java Class
and in the XML instead of
<TextView
tag using something like this: