java - 在 Android 的 Java 文件中编写阿拉伯语

标签 java android arabic

嗨,我想在 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" };

这段代码会像图片中那样写

enter image description here

当我想在这样的位置写阿拉伯语时。 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/

相关文章:

java - 使用 ArrayList 访问特定对象 Java

Java 应用程序在停止时挂起

android - 如何在 Android Studio 中为文本添加下划线?

ios - SwiftUI - 禁用某些 View 从右到左语言翻转

iphone - Xcode .strings 文件似乎不支持阿拉伯文本

java - 使用和不使用 Cloneable 覆盖克隆

java - JVM 和时区

Android Studio - 启动模拟器 AVD - "unable to locate adb"

android - 未经验证的用户可以登录到应用程序。如何预防?

MySQL : Select from table based on shape of arabic character in a column