.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) [英] .IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
问题描述
<!-- 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屋!