【报错】Android:This Activity already has an action bar supplied by the window decor

匿名 (未验证) 提交于 2019-12-03 00:30:01

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.

这主要还是我用android.support.v7.widget包里面的toolbar导致的

修改res/values/style.xml

<!-- 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>  //自己定义的,把actionBar挂掉就可以了,以及TItle     <style name="AppTheme.NoActionBar">         <item name="windowActionBar">false</item>         <item name="windowNoTitle">true</item>     </style>

在Androidmanifest.xml中添加: android:theme=”@style/AppTheme.NoActionBar”

<activity android:name=".MainActivity"           android:theme="@style/AppTheme.NoActionBar">    <intent-filter>       <action android:name="android.intent.action.MAIN" />       <category android:name="android.intent.category.LAUNCHER" />   </intent-filter> </activity>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!