我無法通過功能initFonts()
在我班上的onCreate()
功能,更改文本樣式。沒有錯誤,但沒有任何反應。我正在運行一個無限循環(延遲1秒)的runnable。這是一個問題嗎?無法更改的TextView風格的OnCreate
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);
檢查font.ttf文件..是它的任何文件夾中。? – Riser
是的,它在文件夾 – user6827
看到我的答案在下面。 – Riser