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>


Android四大组件教程——Activity

-
  • 1970年01月01日 08:00

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

使用butterknight出错 原因:更改了id值, 解决方案删除出错activity下的id值,重新生成反射注入id值...
  • cr_lotus1412
  • cr_lotus1412
  • 2017-01-02 18:04:50
  • 3689

java.lang.IllegalStateException: commit already called详细解决办法

1、有问题的代码: class LeftFrag extends Fragment{ private FragmentManager manager; private FragmentTransact...
  • jolin678
  • jolin678
  • 2016-02-16 17:01:53
  • 7718

java.lang.IllegalStateException问题的发现与解决

以上的报错信息挨个查找,分别汇总为以下可能情况 1、tomcat 自启动问题 ,将server.xml重新配置为 reload=false ,依旧没有解决问题 2、内存溢出,将Tomact的内存设...
  • SinsiWoo
  • SinsiWoo
  • 2016-04-20 16:36:20
  • 9763

解决okhttp报java.lang.IllegalStateException: closed,java.lang.IllegalStateException: closed

解决OkHttp请求回调中response.body().string()只能有效调用一次办法在调用了response.body().string()方法之后,response中的流会被关闭,我们需要...
  • x707669224
  • x707669224
  • 2017-02-21 13:10:11
  • 8578

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

springmvc启动项目是报错,如图 报的错即 Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Canno...
  • wudalang_gd
  • wudalang_gd
  • 2016-11-23 13:04:02
  • 2180

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

问题描述: 错误类型大致为以下几种: java.lang.IllegalStateException:Cannot   forward   a   response   that   is...
  • superdog007
  • superdog007
  • 2014-02-27 10:35:48
  • 189921

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

问题:springmvc 启动时出现Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot 原因:...
  • zhenlai2012
  • zhenlai2012
  • 2013-12-13 16:02:50
  • 13985

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

apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "2...
  • zhuhai__yizhi
  • zhuhai__yizhi
  • 2016-10-09 10:49:07
  • 2656

Caused by: java.lang.IllegalStateException: package not installed?

06-26 05:07:17.890: E/AndroidRuntime(3231): FATAL EXCEPTION: main 06-26 05:07:17.890: E/AndroidRunti...
  • tsdfk1455
  • tsdfk1455
  • 2016-11-08 09:35:34
  • 1251
收藏助手
不良信息举报
您举报文章:Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the
举报原因:
原因补充:

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