我无法通过我的类函数initFonts()
中的函数更改文本样式。onCreate()
没有错误,但没有任何反应。我正在运行一个无限循环(延迟 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);