This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_

今天有人问我 This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_

这是个什么错误.首先说一下产生这个错误的原因:

因为当在activity中调用了setSupportActionBar(toolbar); 同时你的AndroidManifest.xml文件中

android:theme="@style/AppTheme"
This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_

并且你的style资源文件中

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_

这时就会报这个异常,那么解决办法有两种:

1.将parent="Theme.AppCompat.Light.DarkActionBar"修改成 parent="Theme.AppCompat.Light.NoActionBar"

2.This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_