开发者

Writing Arabic chars in Android

This is the code I used but every time I excute it force to stop. note that I use it on android 2.1

package com.arb;

import android.app.Activity;

import android.os.Bundle;
im开发者_运维问答port 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){
} 


}
}


Try this, I've just recode several lines, I belive it's working...

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){
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜