嗨,我正在尝试更改 a 的字体样式TextView
。我知道如何更改它,在使用以下代码之前我已经这样做了。
public class Main_Activity extends ListActivity {
Typeface myNewFace = Typeface.createFromAsset(getAssets(),
"fonts/bediz__.ttf");
private CustomListAdapter adap;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
adap = new CustomListAdapter(this);
setListAdapter(adap);
}
public static class CustomListAdapter extends BaseAdapter implements
Filterable {
public View getView(final int position, View convertView,
ViewGroup parent) {
textView.setText(prayers[position]);
holder.textLine.setTypeface(myNewFace);
}
}
我跳过了一些代码,因为没有必要,顺便说一下,当我访问myNewFace
它时,我getView()
要求我制作它static
,当我这样制作static
时
static Typeface myNewFace = Typeface.createFromAsset(getAssets(),"fonts/bediz__.ttf");
它给了我以下错误
Cannot make a static reference to the non-static method getAssets() from the type ContextWrapper
我不知道该怎么办,我以前做过几次这项工作,但现在我不知道为什么它不起作用。