You need to use a Theme.AppCompat theme (or descendant) with this activity
来源:互联网 发布:淘宝我的提问在哪删除 编辑:程序博客网 时间:2024/04/28 05:32
问题现象:
只要添加android:theme="@android:style/Theme.Black.NoTitleBar",APP就会闪退。
错误log:
java.lang.RuntimeException:Unable to start activityComponentInfo{com.example.test2/com.example.test2.MainActivity}:java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (ordescendant) with this activity.
原因:
从错误提示中提到Theme.AppCompat theme,这是因为我们的activity一定是继承了兼容包中的类,
比如我这里就无意中继承了ActionBarActivity,它来自android.support.v7.app.ActionBarActivity。
所以就要使用与其配合的AppCompat的theme才行。
解决方法:
解决两种:
1.根据提示来使用AppCompat的theme,如下:
[html] view plaincopy
- <activity
- android:name=".MainActivity"
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"
- android:label="@string/app_name" >
不过我要设置全屏,但我并没有找到,所以虽然错误不见了,但并没有达到我的预期。
2.如果不是那么强烈需要继承自ActionBarActivity,就直接继承Activity吧。问题自然搞定!
0 0
- 关于“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解决方法
- 【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解决方法
- 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 Studio 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解决方法
- QML概念及框架--继承JavaScript
- web多终端开发学习系列(四)--- web图表插件
- LintCode-跳跃游戏
- 大数据开启的新世界,需要我们改变原有的世界观
- [LeetCode]Word Break II
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- DrawText
- 线程与进程
- [通用问题] iOS 尚未配置微信URL Scheme:wx806574...., 无法进行分享
- CoreData初始识 使用CoreData为数据库添加数据
- Xcode 提示 pie can only be used when targeting iOS 4.2 or
- Prove König's theorem
- eclipse的F3无法定位到声明处(解决方案)
- 多线程总结上篇(基础知识)