Android: Display digits in Arabic format

2019-02-03 21:39发布

How can I show the digits in Arabic format? So, if I have integers: 1,2,3 they become '١', '٢', '٣'

3条回答
劳资没心,怎么记你
2楼-- · 2019-02-03 21:50

If you want to see your number in persian or arabic format, you must use persian or arabic fonts. With android studio's default font you see them in English format . So do like this: 1. Go to this address File \new \ folder \ assets folder You can create a folder that is named as fonts 2. For your textview or edittext that you want to change it's font should do as this

Typeface face=Typeface.createformatassest (getassest (),"fonts/BZAR.TTF"); Textview.settypeface (face);

Fonts is my folder in assets folder.

If you use persian or arabic fonts your numbers format become to arabic format.

查看更多
小情绪 Triste *
3楼-- · 2019-02-03 21:54

set the locale to Arabic, Egypt

NumberFormat nf=NumberFormat.getInstance(new Locale("ar","EG"));
nf.format(i);
查看更多
闹够了就滚
4楼-- · 2019-02-03 21:57
int i = 1;
NumberFormat nf = NumberFormat.getInstance(new Locale("hi", "IN"));
nf.format(i);
查看更多
登录 后发表回答