2

Possible Duplicate:
How to change current Theme at runtime in Android

Hi so I'm nearing the completion of my first app and now there are just some things I'd like to add in for user interface for instance the current mms app I have on my droid is a modded stock one where it has in the settings a check box to change the apps theme between black and white.

I was wondering if someone could show me how to do that or at least point me in the right direction. I've read a few guides on adding check boxes to my app so that's no problem its the actual change how do I put in the code both themes and then set the app to look at one or the other based on the selection of the check box.

Thank you for any input and help.

Community
  • 1
  • 1
GFlam
  • 1,109
  • 4
  • 25
  • 38
  • well like theme.black or theme.light or background color or even font color pretty much anything mostly just interested in changing things like that with check boxes or some sort of dialog and then i'll figure it out from there – GFlam Mar 18 '11 at 19:28

1 Answers1

6

Call Activity.setTheme() in onCreate, before you set up your layout.

EboMike
  • 76,846
  • 14
  • 164
  • 167
  • Okay and then what? are there any guides on this type of stuff? – GFlam Mar 18 '11 at 19:39
  • What are you looking for? Call setTheme() with the Light theme, and your entire UI will use the light theme. Or you can make custom themes. Guide is in the Android docs: http://developer.android.com/guide/topics/ui/themes.html – EboMike Mar 18 '11 at 21:38
  • Presumably you need to know what theme to specify when you call `setTheme`. You could do this the same way that you would read any other user preference. – adamp Mar 18 '11 at 22:23
  • Something I noticed: If you use ActionBarSherlock [YourActivity extends e.g. SherlockFragmentActivity], you need to call .setTheme before super.onCreate(savedInstanceState) - otherwise it does not work right. Just before setContentView(...) is not enough. – nspo Mar 16 '13 at 14:13