Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the

原创 2017年03月09日 09:34:06

 随手记录出现该bug的解决办法


Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not requestWindow.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.


今天新建了一个activity并在activity里面设置这句话


 setSupporActivity(toolbar);


然后就上面这个错误了。

分析可能是因为在application节点中引用了 @style/AppTheme样式,而这个样式自带actionbar

所以我们在activit里面 setSupporActivity(toolbar)就会报这个错误。



解决办法:

去掉代码中的setSupporActivity(toolbar);使用application 的样式

或者在清单文件中 activity节点下加入

<activity android:name=".activity.MainActivity"
    android:theme="@style/AppTheme.NoActionBar"
    />

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>


相关文章推荐

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the

刚在给项目加倒计时广告时遇到一个小错误,尽管错误不是很难解决,但我想分享出来,希望大家不要遇到跟我一样的错误。 错误是: Caused by: java.lang.IllegalStateExce...

java.lang.IllegalStateException: No activity

错误提示: java.lang.IllegalStateException: No activity at android.support.v4.app.FragmentManagerImpl.mov...

java.lang.IllegalStateException: This Activity already has an action bar supplied by the window deco

最近在使用toolbar的过程中遇到了一个error,提示是这样的: ...

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied b

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the ...

java.lang.IllegalStateException: This Activity already has an action bar supplied by the window deco

使用AppCompatActivity的时候,在style中定义了一个AppBaseTheme的样式,继承Theme.AppCompat.Light.NoActionBar,但是在项目运行的时候总是报...

java.lang.IllegalStateException异常产生的原因及解决办法

问题描述: 错误类型大致为以下几种: java.lang.IllegalStateException:Cannot   forward   a   response   that   is...

Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot

问题:springmvc 启动时出现Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot 原因:...

Caused by: java.lang.IllegalStateException: Required view 'descriping' with ID 2131558573 for field

使用butterknight出错 原因:更改了id值, 解决方案删除出错activity下的id值,重新生成反射注入id值...

Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration.

apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "2...

(SSH中使用Proxool问题)java.lang.IllegalStateException: Shutdown in progress__Proxool

Thread-34 ERROR - Problem calling "get cause" on IllegalStateException.java.lang.reflect.InvocationT...
  • jsx112
  • jsx112
  • 2010年09月18日 11:41
  • 3212
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the
举报原因:
原因补充:

(最多只允许输入30个字)