In my app there are a lot of textviews which contain a currency symbol.
Now I want the user to set the symbol. I created a sharedpreference and added there all the existing currencies. Unfortunatelly there are approximately 20 different currencies out there.
Therefor I am struggling how to change dynamically the currency symbol in all my textviews. I could create for each a big switch case statement (with 20 cases) but this will blow up my code extremly.
Is there another technique how I can change the symbol. E.g. with help of an xml file like the different languages...
The efficient way to do this is by using the Locale and Currency classes.
1.Create the Locale object based on the user input
Example:
Locale locale=new Locale("en", "US");
2.based on this get the currency symbol and display it.
Example:
Currency currency=Currency.getInstance(locale);
String symbol = currency.getSymbol();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With