android Bug:You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
2018-02-28 14:12
609 查看
这个问题,不是大问题,,,但是遇到,还是蛮困扰的,,毕竟以前新建AppCompAtctivity都没问题,现在新建的都报错,肯定得从自己工程找原因,,提示很明显:
中文翻译过来意思就是你需要使用一个Theme.AppCompat主题(或继承的主题)对应此activity,我们与之对应的activity是继承于AppCompAtctivity,默认主题是activity的,要想解决问题:
方法一
如果把我们的activity换成继承Activity不会报错,这种方法显然不够完美
方法二
在AndroidManifest.xml中增加声明的Activity一条属性
这样做也不够好,因为以后所有的继承于AppCompAtctivity都需要增加这条属性
方法三
这条方法针对问题形成根源下手,所有的默认主题,都可以根据清单文件application声明中以下属性确定
然后修改res/values/styles.xml
这样就行了,,我的问题就是因为因为疏忽删掉了
希望能帮到有同样问题的人
You need to use a Theme.AppCompat theme (or descendant) with this activity.
中文翻译过来意思就是你需要使用一个Theme.AppCompat主题(或继承的主题)对应此activity,我们与之对应的activity是继承于AppCompAtctivity,默认主题是activity的,要想解决问题:
方法一
如果把我们的activity换成继承Activity不会报错,这种方法显然不够完美
方法二
在AndroidManifest.xml中增加声明的Activity一条属性
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
这样做也不够好,因为以后所有的继承于AppCompAtctivity都需要增加这条属性
方法三
这条方法针对问题形成根源下手,所有的默认主题,都可以根据清单文件application声明中以下属性确定
android:theme="@style/AppTheme"
然后修改res/values/styles.xml
<!-- Base application theme. --> <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> </style>
这样就行了,,我的问题就是因为因为疏忽删掉了
android:theme="@style/AppTheme"
希望能帮到有同样问题的人
相关文章推荐
- Android--You need to use a Theme.AppCompat theme (or descendant) with this activity解决方案
- 【我的Android进阶之旅】解决bug: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.
- 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.
- Android错误之:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android解决在清单文件里消除Bar报错:You need to use a 原来Theme.AppCompat theme (or descendant) with this activity.
- Android issue: 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.
- 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.
- 解决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解决方法