I am getting Arabic text from server successfully. Retrieved text I want display in code but its showing boxes instead of Arabic text. Assume that t
array values are Arabic text from server.
string[] t={" "};
Textview tv = (Textview) findviewByid(R.id.text);
tv.setText(t[0]);
I would like to add my experience after struggling several weeks with Arabic, Actually this post was veryhelpful me when I use arabic fonts in my android application.
I used farsi class to rearrang text. But it is not up to my expectations. because, customer is always too much consider about every letter of the application and it is arrangment.
In the farsi class, one problem is it can't rearrange closing brackets properly. Like that I noticed several issues.
However when I use ArabicUtility class, I noticed that it has improved text rendering better than Farsi class. https://github.com/agawish/Better-Arabic-Reshaper/commits/master
please not that you have to install fonts in assests folder and you can change font type from this class. Additionally I have added a new method to above class in order to get text from string filles and set text to textviews.
here is the code for that.
using above method in your activities, you just have to pass above three parameters.
tv.setTypeFace
and set the proper ttf for the arabictry to copy any arabic font into assets folder and set that font and check may be it works
use the arabic font insted of HandmadeTypewriter.ttf font or
try to set the static arabic text and check its working or not ?
Android 2.1 does not have Arabic font.
Android 2.2 has Arabic font but does not show your word correctly.
Android 3.x supports Arabic completely.
For Android 2.1 you must set the typeface
Farsi.GetFarsiFont(this)
and then useFarsi.Convert("سلام")
For Android 2.2 you do not need setting font but must use
Farsi.Convert("سلام")
And for Android 3.x forget all of the above solutions ;). But you can change the font if you do not like the 3.x Arabic font.
so do the following steps:
1) At first add "TAHOMA.TTF" in assets folder
2) use the following class to get the font and converting your Arabic or Farsi text to a good form for showing in your activities.
3) And in your Activity:
enjoy!
my reference for Farsi class: Arabizer