Why Getapplicationcontext().settheme() In A Activity Does Not Work?
Solution 1:
I had the same problem before and didn't find a way to fix this. Only god knows why, but I've even seen Android framework engineers (I believe it was Dianne Hackborn) say that setting themes like this is discouraged.
Set the theme for your Activity in the Manifest instead, and it will work.
Solution 2:
you can use setTheme(..)
before calling setContentView(...)
and super.oncreate()
and it should work fine
Solution 3:
When do you call setTheme() on your application context? It must be called before instantiating any views.
Solution 4:
you can use
setTheme(..)
before callingsetContentView(...)
andsuper.oncreate()
and it should work fine
It's fixed in sdk 4.0 (may be earlier).
Solution 5:
I didn't try this out myself, but if it was absolutely necessary to set the theme programatically, the next thing I'd try would be to derive a class from Application and override the onCreate method like in the following:
publicclassMyApplicationextendsandroid.app.Application {
@OverridepublicvoidonCreate() {
super.onCreate();
setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen);
}
}
Post a Comment for "Why Getapplicationcontext().settheme() In A Activity Does Not Work?"