在Android中编写阿拉伯语字符

时间:2010-06-27 22:29:02

标签: android arabic

这是我使用的代码 但每次我执行它都要强制停止。 请注意我在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){
} 


}
}

1 个答案:

答案 0 :(得分: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){
}