Intent之后activitybar报错This Activity already has an action bar supplied by the window decor.

本文主要是介绍Intent之后activitybar报错This Activity already has an action bar supplied by the window decor.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

解决一个app的theme在intent之后与module之后的theme兼容的问题

程序中使用intent跳转到一个新的activity,这个activity是作为module导入,强行合成的一个工程,跳转的时候闪退并且会报错

 

 Process: com.xx.Dxxxxxxxxxx, PID: 4500java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.Dxxxxxxxxxx/com.example.xx.Dxxxxxxxxxx.activities.MainActivity}: 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.at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3107)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3250)at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1947)at android.os.Handler.dispatchMessage(Handler.java:106)at android.os.Looper.loop(Looper.java:214)at android.app.ActivityThread.main(ActivityThread.java:7032)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)Caused by: 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.at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:201)at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:129)at com.example.xx.Dxxxxxxxxxx.activities.MainActivity.initToolbar(MainActivity.java:418)at com.example.xx.Dxxxxxxxxxx.ui.activities.MainActivity.initViews(MainActivity.java:309)at com.example.xx.Dxxxxxxxxxx.ui.activities.MainActivity.onCreate(MainActivity.java:174)at android.app.Activity.performCreate(Activity.java:7327)at android.app.Activity.performCreate(Activity.java:7318)at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3087)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3250) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1947) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7032) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) 

查看问题定位

setSupportActionBar(toolbar);

根据问题搜索到这篇文章:

https://www.cnblogs.com/hh9601/p/6404728.html

按照博主的方法把原styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"><item name="colorPrimary">@color/white</item><item name="colorPrimaryDark">@color/white</item><item name="colorAccent">@color/colorAccent</item><item name="actionOverflowMenuStyle">@style/CKMenuStyle</item></style>

改为

<style name="AppTheme.NoActivityBar""><item name="windowActionBar">false</item><item name="windowNoTitle">true</item></style>

之后不再报错,正常打开,但是界面颜色不对,等于把app的theme去掉也把module本来的主题也去掉了

想要module之后的theme和APP中的theme分离开,于是,接着把styles.xml改为:

<style name="Theme.AppCompat.Light.NoActionBar.NoActivityBar" parent="Theme.AppCompat.Light.NoActionBar"><item name="windowActionBar">false</item><item name="windowNoTitle">true</item><item name="colorPrimary">@color/white</item><item name="colorPrimaryDark">@color/white</item><item name="colorAccent">@color/colorAccent</item><item name="actionOverflowMenuStyle">@style/CKMenuStyle</item></style>

显示正确,问题解决

这篇关于Intent之后activitybar报错This Activity already has an action bar supplied by the window decor.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/540318

相关文章

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

MyBatis模糊查询报错:ParserException: not supported.pos 问题解决

《MyBatis模糊查询报错:ParserException:notsupported.pos问题解决》本文主要介绍了MyBatis模糊查询报错:ParserException:notsuppo... 目录问题描述问题根源错误SQL解析逻辑深层原因分析三种解决方案方案一:使用CONCAT函数(推荐)方案二:

Spring Boot中JSON数值溢出问题从报错到优雅解决办法

《SpringBoot中JSON数值溢出问题从报错到优雅解决办法》:本文主要介绍SpringBoot中JSON数值溢出问题从报错到优雅的解决办法,通过修改字段类型为Long、添加全局异常处理和... 目录一、问题背景:为什么我的接口突然报错了?二、为什么会发生这个错误?1. Java 数据类型的“容量”限制

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring

解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml'

《解决SpringBoot启动报错:Failedtoloadpropertysourcefromlocationclasspath:/application.yml问题》这篇文章主要介绍... 目录在启动SpringBoot项目时报如下错误原因可能是1.yml中语法错误2.yml文件格式是GBK总结在启动S

idea maven编译报错Java heap space的解决方法

《ideamaven编译报错Javaheapspace的解决方法》这篇文章主要为大家详细介绍了ideamaven编译报错Javaheapspace的相关解决方法,文中的示例代码讲解详细,感兴趣的... 目录1.增加 Maven 编译的堆内存2. 增加 IntelliJ IDEA 的堆内存3. 优化 Mave

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

浅谈配置MMCV环境,解决报错,版本不匹配问题

《浅谈配置MMCV环境,解决报错,版本不匹配问题》:本文主要介绍浅谈配置MMCV环境,解决报错,版本不匹配问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录配置MMCV环境,解决报错,版本不匹配错误示例正确示例总结配置MMCV环境,解决报错,版本不匹配在col

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

springboot报错Invalid bound statement (not found)的解决

《springboot报错Invalidboundstatement(notfound)的解决》本文主要介绍了springboot报错Invalidboundstatement(not... 目录一. 问题描述二.解决问题三. 添加配置项 四.其他的解决方案4.1 Mapper 接口与 XML 文件不匹配