尝试启动我的应用程序时出现此异常,为什么?

Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.



  样式文件
      


    <!-- 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>

    </style>
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>


有人可以帮我吗?

谢谢

最佳答案

该错误表明您的活动不支持Window.FEATURE_SUPPORT_ACTION_BAR

因此您可以在活动布局中使用toolbar

这是Good Example

另外,您需要在清单中正确设置activity主题。

采用:

<activity
    android:name=".activity.YourActivity" //the activity where you got the crash
    android:theme="@style/AppTheme.NoActionBar">  //add this

07-27 17:42