Set Indian Rupee symbol on text view

ぃ、小莉子 提交于 2019-11-27 00:19:36

问题


I am developing an application. And i need to set the symbol of Indian rupee on text view which is set with the text as amount.

Symbol:

I am having the font or .TTF file of this in Assets/fonts folder.

And i tried to use it as :

Typeface typeFace_Rupee = Typeface.createFromAsset(getAssets(),fonts/Rupee_Foradian.ttf");
TextView tvRupee = (TextView) findViewById(R.id.textview_rupee_mlsaa);
tvRupee.setTypeface(typeFace_Rupee);

// Tried to set symbol on text view as follows.
tvRupee.setText("`");

As above setting font i got null pointer error.

In word file after choosing font and typing ` we got the symbol. but it is not working in android.

So what steps should i follow to do this...


回答1:


Hi use this in Strings

For print rupee symbol: <string name="Rs">\u20B9</string>

For print Rs text: <string name="rs">\u20A8</string>




回答2:


Use \u20B9 if you want to print the Rupee Symbol
and
Use \u20A8 if you want to print "Rs"




回答3:


Try this, Instead of Rupee_Foradian.ttf use Rupee.ttf it will work. am getting currency symbol.

Typeface tf = Typeface.createFromAsset(getAssets(), "font/Rupee.ttf");
textView1.setTypeface(tf);
textView1.setText("`");



回答4:


use on Adapter

Viewholder.price.setText("Price: \u20B9"+dataAdapterOBJ.getPrice());



回答5:


Copy paste the unicode ₹ to XML or Java and it works just fine. For more info on the unicode refer http://www.fileformat.info/info/unicode/char/20b9/index.htm




回答6:


Try this code snippet it's working fine in Xamarin.Forms

 CultureInfo india = new CultureInfo("hi-IN");

 var rupeeSymbol = india.NumberFormat.CurrencySymbol;



回答7:


 public static String getIndianRupee(String value) {
    Format format = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
    return format.format(new BigDecimal(value));
}


来源:https://stackoverflow.com/questions/15158754/set-indian-rupee-symbol-on-text-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!