Android:尝试更改操作栏的背景时出错

时间:2013-12-12 09:04:45

标签: android android-actionbar action

我正在尝试更改操作栏的背景颜色。 我正在关注本网站的教程: http://developer.android.com/training/basics/actionbar/styling.html
关于设置操作栏样式的章节

我收到一个错误,我无法弄清楚它的起源。 错误发生在这行代码

Android Manifest.xml
android:theme="@style/CustomActionBarTheme"

错误:错误:找不到与给定名称匹配的资源(在'theme'处,值为'@ style / CustomActionBarTheme')。 任何人都可以解释为什么这一行会抛出错误?

代码:      Android Manifest.xml          

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/CustomActionBarTheme"
    android:uiOptions="splitActionBarWhenNarrow" >

    <activity
        android:name="com.example.myfirstapp2.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.myfirstapp2.DisplayMessageActivity"
        android:label="@string/title_activity_display_message"
        android:parentActivityName="com.example.myfirstapp.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.myfirstapp.MainActivity" />
    </activity>
    </application>

   </manifest>

代码:themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
       parent="@style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/actionbar_background</item>
</style>
</resources>

code:styles.xml

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go    

 here. -->
</style>

 </resources>

0 个答案:

没有答案