Android报错之This Activity already has an action bar supplied by the window decor 2.0

一、报错

在这里插入图片描述
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.

二、解决方法

1.修改themes.xml,添加style代码

在这里插入图片描述

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

2.修改Androidmanifest.xml,在相应的Activity里加入android:theme=“@style/Theme.TYLDApp.NoActionBar”

在这里插入图片描述

 android:theme="@style/Theme.TYLDApp.NoActionBar"

完美解决!!!

猜你喜欢

转载自blog.csdn.net/qq_61963074/article/details/126791563