在安卓系统中如何书写阿拉伯字符

3

这是我使用的代码,但每次执行时都会强制停止。 请注意,我在Android 2.1上使用它。

package com.arb;

import android.app.Activity;

import android.os.Bundle;
import android.widget.TextView;
import android.content.res.AssetManager;
import android.graphics.Typeface;

public class arabi extends Activity
{
AssetManager arabi_font;

TextView tx;


    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
tx=(TextView) this.findViewById(R.id.tt);

try{

arabi_font.open("DejaVuSans.ttf");

//DejaVuSans.ttf font file

tx.setTypeface(Typeface.createFromAsset(arabi_font,"DejaVuSans.ttf"));
tx.setText("\uFEB3\uFE92\uFE98\uFE94");
}


catch(Exception ex){
} 


}
}

还有,你能发布一下你的应用程序日志吗? - Cristian
我的应用程序的日志是什么意思? - SultanSh
adb shell logcat > file。至少在Linux上 :) - Macarse
我没有使用Linux,我如何在Eclipse中提供它? - SultanSh
你可以在这个链接找到你的解决方案。享受吧! :) - Bobs
1个回答

0

试试这个,我刚刚重新编写了几行代码,我相信它可以工作...

try{

   //arabi_font.open("DejaVuSans.ttf");

   //DejaVuSans.ttf font file

   tx.setTypeface(Typeface.createFromAsset(getAssets(),"DejaVuSans.ttf"));
   tx.setText("\uFEB3\uFE92\uFE98\uFE94");
}
catch(Exception ex){
} 

完整代码位于http://blog.kerul.net/2010/12/connected-arabic-characters-for-android.html。感谢Amr Gawish。 - Khirulnizam Abd Rahman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接