2011-06-06 72 views
0

與Android開發相比,我是一個新手,我只是通過示例項目來獲取它的一個掛起。我只是試圖從Wikitionary(一個android SDK附帶的示例應用程序)複製樣式。Android主題奇怪的​​問題

<style name="LookupTheme" parent="@android:style/Theme.Light"> 
    <item name="android:windowBackground">@drawable/lookup_bg</item> 
</style> 

並將其指定爲清單文件中的默認主題。這樣產生了一個效果。 enter image description here

這正是我想要的。現在我添加了一個首選項頁面,允許用戶從要應用的主題列表中進行選擇。因此,我從清單文件中刪除了主題屬性(以使用默認主題),我嘗試以編程方式應用主題。像這樣

SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(act.getApplicationContext()); 
    String themeid = sPref.getString("theme_pref", "1"); 
    int themeID = Integer.valueOf(themeid); 
    if(themeID== 2){ 
     Log.d(Constants.LOG_TAG, "Light theme have been choosen"); 
     act.setTheme(R.style.LookupTheme); 
    } 

現在,相同的主題以編程方式應用(與聲明式方法相反)併產生如下效果。 enter image description here

有人可以解釋這裏有什麼問題嗎?

回答