Android 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
来源:互联网 发布:淘宝中老年女冬装 编辑:程序博客网 时间:2024/04/28 18:38
原文地址:http://blog.csdn.net/ouyang_peng
#1、错误描述
今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性
- 1
- 1
具体代码如下:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
结果运行app的时候,报了如下错误:
- 1
- 1
具体错误log如下:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
如下图所示:
2、错误分析
原来我的Activity继承自 Android.support.v7.app.AppCompatActivity,而不是 android.app.Activity。
3、解决方法
方法1:
创建的activity时,如果不是那么强烈需要继承自AppCompatActivity,就直接继承Activity。
如将activity继承自AppCompatActivity:
- 1
- 1
改成activity继承自Activity:
- 1
- 1
方法2:
还是想继承自AppCompatActivity,那么根据提示来使用AppCompat的theme,即将AndroidManifest.xml文件中关于Activity的主题配置改成:
- 1
- 1
完整代码如下:
0 0
- Android 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity错误解决
- 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android错误之:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决
- 【已解决】You need to use a Theme.AppCompat theme (or descendant) with this activity
- 解决You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android开发~you need to use a theme.appcompat theme (or descendant) with this activity
- 【Android】You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- Android Studio You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- Android Studio中报错 You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android问题一:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android--You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
- Android异常-You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 机器人操作系统ROS Indigo 入门学习(4)——创建一个ROS Package
- leetcode
- 远离超速,远离大货车,看完懂得生命的珍贵
- IDEA如何打包可运行jar的一个问题
- 从零开始学习Vue(三)
- Android 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- java.io.File中的pathSeparator、separatorChar与separator的区别
- 图表插件
- linux环境下搭建mysql主从复制
- 【图像处理】图像标签
- leetcode
- 哈希表的C++实现(线性探测)
- linux c之snprintf()和sprintf()区别
- Android四大组件之BroadcastReceiver