嗨,我想在 Android 中用 Java 编写阿拉伯语,这是代码
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" };
这段代码会像图片中那样写
当我想在这样的位置写阿拉伯语时。 location=new String[]{"مستشوى هبه"}
就是要工作,出现奇怪的字样
最佳答案
Android 无法处理简单的阿拉伯字母 (unicode 0x06xx)。您需要使用阿拉伯文表示字符 (0xFExx),并自己将这些字母连接在一起。
您还需要在网络上找到一种漂亮的阿拉伯字体——我使用“AGA Rashheeq Bold”——并将其放入您的 Assets 中,然后像这样加载它
Typeface tfArabic = Typeface.createFromAsset (getAssets (), "AGA-Rasheeq-Bold.ttf");
然后使用类似这样的方式来使用字体:
NextButton.setTypeface (tfArabic);
关于java - 在 Android 的 Java 文件中编写阿拉伯语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19067956/