【问题标题】:Crash on android 4.4.2: This Activity already has an action bar supplied by the window decor在 android 4.4.2 上崩溃:此 Activity 已经有一个由窗口装饰提供的操作栏
【发布时间】:2016-03-14 14:00:04
【问题描述】:

当我在 android 4.4.2 中运行我的应用程序时出现此错误:

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

我正在使用工具栏,并将基本主题设置为 .NoActionBar,所以它应该可以正常工作。

这是我的默认主题.xml:

 <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

我也尝试过windowActionBar = falsewindowNoTitle = true,但仍然无法正常工作。
有人可以帮我解决这个错误吗?

编辑 在清单中我只是这样做:

android:theme="@style/AppTheme.Mezzo" 

 <style name="AppTheme.Mezzo" parent="AppTheme.Base">
 ...
 </style>

【问题讨论】:

  • 您确定您的活动没有使用清单中声明的​​其他主题吗?
  • 不,在清单中我只是将应用程序的主题设置为 AppTheme.Base 的子项。

标签: android android-actionbar android-toolbar android-theme


【解决方案1】:

尝试使用这种风格

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:windowContentTransitions">true</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

并在清单中使用它

 android:theme="@style/AppTheme.NoActionBar" 

在您的活动标签中

【讨论】:

  • 刚试了还是不行...不知道现在该怎么办,你们还需要什么其他信息?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-16
  • 2016-04-22
  • 1970-01-01
  • 2017-01-13
  • 2015-03-03
相关资源
最近更新 更多