2013-06-21 53 views
0

我無法通過功能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); 
+0

檢查font.ttf文件..是它的任何文件夾中。? – Riser

+0

是的,它在文件夾 – user6827

+0

看到我的答案在下面。 – Riser

回答

0
Typeface font = Typeface.createFromAsset(getAssets(), "foldername/font.ttf"); 
cur.setTypeface(font); 
+0

不行,這是行不通的,它是在資產根文件夾 – user6827

+0

中放上你編輯好的代碼。 – Riser

+0

它是textview不起作用。我甚至不能設置一個聽衆 – user6827