.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

早过忘川 提交于 2019-12-20 07:39:53

问题


<!-- 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>

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.


回答1:


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




回答2:


In your Android Studio, click on the "theme button" and select the appCompat theme in the dialog.



来源:https://stackoverflow.com/questions/32376815/illegalstateexception-you-need-to-use-a-theme-appcompat-theme-or-descendant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!