【发布时间】:2015-12-19 12:28:01
【问题描述】:
我正忙于实现支持库,以便我可以使用AppCompatActivty
据我所知,我把所有东西都放在了正确的地方。但我仍然收到错误消息。
styles.xml
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
manifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher_on"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
activity.java
public class RegisterActivity extends AppCompatActivity
现在,当我运行我的应用程序并尝试打开 RegisterActivty 时,我收到以下错误。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tuta_me/activities.RegisterActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
我一定是在什么地方漏掉了什么。我做错了什么?
【问题讨论】:
标签: java android xml android-appcompat android-theme