【问题标题】:change theme on ActionBarActivity on android 4.3 api 18在 android 4.3 api 18 上更改 ActionBarActivity 的主题
【发布时间】:2013-07-29 15:09:44
【问题描述】:

您好,我想在运行时更改我的应用主题,使用 actionBar 兼容性(新 api 18)这是我的主题:

    <style name="AppThemeDay" parent="@style/Theme.AppCompat.Light">
      <item name="android:actionBarSize">....</item>
    </style>

    <style name="AppThemeNight" parent="@style/Theme.AppCompat">
      <item name="android:actionBarSize">...</item>
    </style>

现在我想将主题更改为我的 ActionBarActivity:

if(day){
  setTheme(R.style.AppThemeDay);
} else{
    setTheme(R.style.AppThemeNight);
}

但我没有零钱。为什么?

【问题讨论】:

  • 你读过 setTheme 文档吗?
  • 阅读文档!!!!!! 为此上下文设置基本主题。请注意,这应该在上下文中实例化任何视图之前调用(例如在调用 setContentView(View)inflate(int, ViewGroup) 之前)。

标签: android android-actionbar android-4.3-jelly-bean android-actionbar-compat


【解决方案1】:

感谢您的回复!我在 setContentView(View) 之后调用了 setTheme..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    • 2017-06-21
    • 1970-01-01
    相关资源
    最近更新 更多