我无法通过我班级的initFonts()
函数中的函数onCreate()
更改文本样式。没有错误,但没有任何反应。我正在运行一个无限循环的runnable(延迟1秒)。这是一个问题吗?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initFonts();
// Start a load dialog
progressdialog = new ProgressDialog(MainActivity.this);
progressdialog.setTitle("Please wait");
progressdialog.setMessage("Loading...");
progressdialog.setCancelable(false);
progressdialog.show();
// Start updating all lists
runnable = new Runnable() {
public void run() {
updateList();
}
};
// Keep it running
runnable.run();
}
我正在更改initFonts()
方法中的字体:
TextView cur = (TextView)findViewById(R.id.current);
TextView plus = (TextView)findViewById(R.id.plus);
TextView min = (TextView)findViewById(R.id.min);
cur.setTextSize(150);
Typeface font = Typeface.createFromAsset(getAssets(), "font.ttf");
cur.setTypeface(font);
plus.getBackground().setAlpha(45);
min.getBackground().setAlpha(45);
答案 0 :(得分:0)
Typeface font = Typeface.createFromAsset(getAssets(), "foldername/font.ttf");
cur.setTypeface(font);