【发布时间】:2015-01-21 18:44:56
【问题描述】:
我刚刚使用 (hamburger) drawer 创建了 Android 项目,midSDKlevel 设置为 android-8。
,然后在 Android 5.0 模拟器中运行我得到了 RuntimeException
原因:java.lang.IllegalStateException:您需要在此活动中使用 Theme.AppCompat 主题(或后代)。
\app\src\main\res\values-v21\styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
</resources>
Android 清单
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
使用 AppCompat 进行 Material Design 的确切字符串应该是什么?
【问题讨论】:
-
检查您的 Android 清单中的主题?
-
它有
android:theme="@style/AppTheme"
标签: android android-support-library android-5.0-lollipop material-design