Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Display digits in Arabic format

Tags:

android

arabic

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

like image 863
Mina Wissa Avatar asked Jul 02 '15 13:07

Mina Wissa


3 Answers

set the locale to Arabic, Egypt

NumberFormat nf=NumberFormat.getInstance(new Locale("ar","EG"));
nf.format(i);
like image 141
Mina Wissa Avatar answered Nov 08 '22 15:11

Mina Wissa


int i = 1;
NumberFormat nf = NumberFormat.getInstance(new Locale("hi", "IN"));
nf.format(i);
like image 32
Max77 Avatar answered Nov 08 '22 14:11

Max77


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.

like image 36
Homa Avatar answered Nov 08 '22 14:11

Homa