新建MainActivity继承AppCompatActivity后在onCreate中调用setSupportActionBar(toolbar)时报如下错误:
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.
解决方案:
AndroidMenifest.xml中声明MainActivity中添加 android:theme="@style/AppTheme.NoActionBar"
<style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style>