0
public class XYZ extends LinearLayout{

     TextView text  = (TextView) findViewById(R.id.kid_name);
    Typeface font = Typeface.createFromAsset(getAssets(), "eng111.ttf");
    text.setTypeface(font);
}

我只是尝试对文本使用其他格式,然后出现问题“创建 getAssets() 方法”

我哪里错了?请解决这个问题

4

1 回答 1

2

你需要一个Context,因为你不在Activity你需要打电话:

getContext().getAssets();
于 2013-06-03T12:58:21.270 回答