Guido García Guido García - 6 months ago 48
Android Question

How to change current Theme at runtime in Android

I've created a PreferenceActivity that allows the user to choose the theme he wants to apply to the entire application.

When the user selects a theme, this code is executed:

if (...) {
} else {

But, even though I've checked with the debugger that the code is being executed, I can't see any change in the user interface.

Themes are defined in
, and Eclipse does not show any error.

<style name="LightTheme" parent="@android:style/Theme.Light">

<style name="BlackTheme" parent="@android:style/Theme.Black">

Any idea about what could be happening and how to fix it?
Should I call
at any special point in the code? My application consists of several Activities if that helps.


I would like to see the method too, where you set once for all your activities. But as far I know you have to set in each activity before showing any views.

For reference check this:

Edit (copied from that forum):

protected void onCreate(Bundle savedInstanceState) {

    // Call setTheme before creation of any(!) View.

    // ...