Вопрос

I have a text view name total I want to add a $ symbol in-front so that when i key in a number in the textview, it will appear as currency, Eg.$20 instead of 20

but at other part of my code later, i will also need to get value from this textview which need to exclude the $ symbol

please show me the easiest way to do this

Thank you

Это было полезно?

Решение

You can create an icon for the dollar symbol, and set it as the left drawable:

TextView textView = (TextView) findViewById(R.id.myTxtView);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon, 0, 0, 0);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top