Home » Android » Android: Display digits in Arabic format

Android: Display digits in Arabic format

Posted by: admin June 15, 2020 Leave a comment

Questions:

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

How to&Answers:

set the locale to Arabic, Egypt

NumberFormat nf=NumberFormat.getInstance(new Locale("ar","EG"));
nf.format(i);

Answer:

int i = 1;
NumberFormat nf = NumberFormat.getInstance(new Locale("hi", "IN"));
nf.format(i);

Answer:

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.