开发者

Writing Arabic chars in Android

开发者 https://www.devze.com 2023-01-05 08:55 出处:网络
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;

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

精彩评论

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

关注公众号