如何在eclipse中使用自定义字体?

use*_*679 2 android

可能重复:
Android - 使用自定义字体

我正在创建一个阿拉伯语的应用程序,并有一个我想使用的自定义字体可以有人告诉我我应该在我的java类中使用的代码我试过这个

TextView txt = (TextView) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(getAssets(), "trado.ttf");  
txt.setTypeface(font); 
Run Code Online (Sandbox Code Playgroud)

但是结尾行显示字体是一个错误,表示令牌"font"上的语法错误,此令牌后的VariableDeclaratorId可以有人帮忙!

Bil*_*ary 5

试试这个,就像添加thislol一样

TextView txt = (TextView) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(this.getAssets(), "trado.ttf");  
txt.setTypeface(font); 
Run Code Online (Sandbox Code Playgroud)