Android 您需要在此活动中使用Theme.AppCompat主题(或子代)。API 16
我遇到了与相同的问题,但是我检查了代码和xml文件,我只使用AppCompat。我正在尝试在api 16上运行。我在这里使用它: 在我错过的地方,有什么建议吗?试试这个,换个新的Android 您需要在此活动中使用Theme.AppCompat主题(或子代)。API 16,android,xml,android-appcompat,Android,Xml,Android Appcompat,我遇到了与相同的问题,但是我检查了代码和xml文件,我只使用AppCompat。我正在尝试在api 16上运行。我在这里使用它: 在我错过的地方,有什么建议吗?试试这个,换个新的 android:theme="@style/AppTheme" > 借 如果“MainActivity”是AppActivity的子项,请尝试将min api设置为16或使用一些附加库,如检查清单文件(如果已将任何不兼容的主题添加到应用程序中)。其主题应继承自theme.AppCompat或其 孩子们。您在活动
android:theme="@style/AppTheme" >
借
如果“MainActivity”是AppActivity的子项,请尝试将min api设置为16或使用一些附加库,如检查清单文件(如果已将任何不兼容的主题添加到应用程序中)。其主题应继承自theme.AppCompat或其
孩子们。您在活动中使用了工具栏吗?@ProkashSarkar,是的,我使用了cutom工具栏。这很有帮助,但我想知道为什么需要直接继承人的活动。
<!-- Base application theme. -->
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@color/background_material_light</item>
</style>
<style name="AppTheme" parent="Base.AppTheme">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<!-- <item name="android:navigationBarColor">@color/primary_dark</item>-->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:124)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.dandewine.user.tocleveroad.MainActivity.onCreate(MainActivity.java:39)
android:theme="@style/AppTheme" >
android:theme="@style/Base.AppTheme" >