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

相关文章

如何在页面调用utility bar并传递参数至lwc组件

1.在app的utility item中添加lwc组件: 2.调用utility bar api的方式有两种: 方法一,通过lwc调用: import {LightningElement,api ,wire } from 'lwc';import { publish, MessageContext } from 'lightning/messageService';import Ca

Jenkins 插件 地址证书报错问题解决思路

问题提示摘要: SunCertPathBuilderException: unable to find valid certification path to requested target...... 网上很多的解决方式是更新站点的地址,我这里修改了一个日本的地址(清华镜像也好),其实发现是解决不了上述的报错问题的,其实,最终拉去插件的时候,会提示证书的问题,几经周折找到了其中一遍博文

利用matlab bar函数绘制较为复杂的柱状图,并在图中进行适当标注

示例代码和结果如下:小疑问:如何自动选择合适的坐标位置对柱状图的数值大小进行标注?😂 clear; close all;x = 1:3;aa=[28.6321521955954 26.2453660695847 21.69102348512086.93747104431360 6.25442246899816 3.342835958564245.51365061796319 4.87

【Python报错已解决】AttributeError: ‘list‘ object has no attribute ‘text‘

🎬 鸽芷咕:个人主页  🔥 个人专栏: 《C++干货基地》《粉丝福利》 ⛺️生活的理想,就是为了理想的生活! 文章目录 前言一、问题描述1.1 报错示例1.2 报错分析1.3 解决思路 二、解决方法2.1 方法一:检查属性名2.2 步骤二:访问列表元素的属性 三、其他解决方法四、总结 前言 在Python编程中,属性错误(At

DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed

DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed 文章目录 DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed问题解决办法 问题 使用 DBeaver 连接 MySQL 数据库的时候, 一直报错下面的错误 Public Key Retrieval is

js window.addEventListener 是什么?

window.addEventListener 是 JavaScript 中的一个方法,用于向指定对象(在这个情况下是 window 对象,代表浏览器窗口)添加事件监听器,以便在该对象上发生特定事件时执行相应的函数(称为事件处理函数或事件监听器)。 这个方法接受三个参数: 事件类型(type):一个字符串,表示要监听的事件类型。例如,"click" 表示鼠标点击事件,"load" 表示页面加

Unable to instantiate Action, goodsTypeAction, defined for 'goodsType_findAdvanced' in namespace '/

报错: Unable to instantiate Action, goodsTypeAction,  defined for 'goodsType_findAdvanced' in namespace '/'goodsTypeAction......... Caused by: java.lang.ClassNotFoundException: goodsTypeAction.......

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef‘ of undefined“

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef’ of undefined” 最近用vue做的一个界面,引入了一个子组件,在父组件中调用子组件的方法时,报错提示: [Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘methods

Qt中window frame的影响

window frame 在创建图形化界面的时候,会创建窗口主体,上面会多出一条,周围多次一圈细边,这就叫window frame窗口框架,这是操作系统自带的。 这个对geometry的一些属性有一定影响,主要体现在Qt坐标系体系: 窗口当中包含一个按钮,这个按钮的坐标系是以父元素为参考,那么这个参考是widget本体作为参考,还是window frame作为参考,这两种参考体系都存在

Vue3上传图片报错:Current request is not a multipart request

当你看到错误 "Current request is not a multipart request" 时,这通常意味着你的服务器或后端代码期望接收一个 multipart/form-data 类型的请求,但实际上并没有收到这样的请求。在使用 <el-upload> 组件时,如果你已经设置了 http-request 属性来自定义上传行为,并且遇到了这个错误,可能是因为你在发送请求时没有正确地设置