I am trying to get a user-selected theme and I feel upset. The theme definition in AndroidManifest.xml works as it should, but (as far as I can tell) it cannot change depending on the settings of the application:
<application android:theme="@style/theme_sunshine" android:icon="@drawable/icon" android:label="@string/app_name">
Alternatively, setting dynamically in each action also works:
someChosenTheme = PreferenceManager.getDefaultSharedPreferences(this).getString("themePreference", "theme_twilight"); setTheme(someOtherChosenTheme);
But that seems messy, and I would rather install the theme for the entire application in one place. My first thought was to capture the context of the application as soon as my main activity starts and do this:
getApplicationContext().setTheme(R.style.theme_dummy);
As far as I can tell, this one should do the trick, but in fact it does nothing - the whole application has a default value of Android Style. Is this higher, and if so, can I do something else dumb?
I work at API level 3 if that matters. Virtues in the right direction are greatly appreciated!
Related question.
android themes android-theme
Cheezmeister Jan 11 '11 at 23:13 2011-01-11 23:13
source share