.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) [英] .IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

查看:63
本文介绍了.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>

这是我的代码,显示这样的错误java.lang.RuntimeException:无法启动活动ComponentInfo {com.colors.floatingactionbutton/com.colors.floatingactionbutton.MainActivity}:java.lang.IllegalStateException:您需要对此活动使用Theme.AppCompat主题(或后代).

This is my code Showing error like this java.lang.RuntimeException: Unable to start activity ComponentInfo{com.colors.floatingactionbutton/com.colors.floatingactionbutton.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

推荐答案

您需要使用AppCompact库的一个主题,例如 @ style/Theme.AppCompat.Light ,而不是 android:Theme.Material.Light.NoActionBar

You need to use one theme of the AppCompact library like @style/Theme.AppCompat.Light instead of android:Theme.Material.Light.NoActionBar

这篇关于.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆