문제

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