Reputation: 13
Hi I want to write Arabic in Java in Android and this is the code
public class hospital extends Activity {
ListView listView,l1;
ArrayAdapter<String> adapter,adapter1,adapter2;
String[] location,loc1,loc2;
Button home,map;
TextView name,address,phone;
WebView maps;
String hospital_name,hospital_address,hospital_phone,url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hospital_location);
home = (Button)findViewById(R.id.home);
home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(hospital.this, MainActivity.class ));
finish();
}
});
listView = (ListView) findViewById(R.id.hospital_list_location);
location = new String[] { "Al rabia","Tabarbor","Tla' al Ali","Daheat elrawda" };
This code will write like in the photo
And when I want to write Arabic in location like this. location=new String[]{"مستشفى هبه"}
It's want work and appear a strange words
Upvotes: 1
Views: 557
Reputation: 378
Android can't handle the simple arabic letters (unicode 0x06xx). You need to use arabic presentation characters (0xFExx), and join the letters together yourself.
You also need to find a nice arabic font on the web- I use "AGA Rashheeq Bold"- and put it into your assets, then load it like this
Typeface tfArabic = Typeface.createFromAsset (getAssets (), "AGA-Rasheeq-Bold.ttf");
Then use something like this to use the font:
NextButton.setTypeface (tfArabic);
Upvotes: 1