我正在尝试使用 setTheme 函数,该函数基本上根据一些 DB 值设置主题,但问题是一旦我用要设置的主题更新了 DB,我需要完成()要实现主题设置的活动。代码是 -
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settingsDBAdapter = new SettingsDBAdapter(this);
settingsDBAdapter.open();
setSettingsTheme(); <<------THIS LINE WILL SET THEME
setContentView(R.layout.layout_task_manager);
quickAddButton = (Button) findViewById(R.id.QuickAddButtonId);
quickAddTaskText = (EditText) findViewById(R.id.QuickAddEditTextId);
mDBHelper = new TasksDBAdapter(this);
mDBHelper.open();
fillData();
//code to create long press on any list item and calls onCreateContextMenu method
registerForContextMenu(getListView());
registerButtonListenersAndSetDefaultText();
}
public void setSettingsTheme(){
String currentTheme = settingsDBAdapter.fetchThemeSettings("theme");
Log.i(TAG,"settingsDBAdapter + currentTheme-->" + settingsDBAdapter + currentTheme);
//setTheme(R.style.HoloTheme);
if(currentTheme.trim().equalsIgnoreCase("holo")){
Log.i(TAG, "in holo<<<<<<<<");
setTheme(R.style.HoloTheme);
}else if(currentTheme.trim().equalsIgnoreCase("hololight")){
Log.i(TAG, "in hololight<<<<<<<");
setTheme(R.style.HoloLightTheme);
}else{
Log.i(TAG, "iin else<<<<<<<");
setTheme(R.style.HoloTheme);
}
}
我还尝试在覆盖 onResume() 函数后调用 setSettingsTheme() 函数仍然没有用。Log.i
存在于 setSettingsTheme() 函数中总是给出正确的值。任何人都可以帮助我理解。提前致谢,考希克