1

I am trying to do change the background color of the action bar. I am following tutorial from this site: http://developer.android.com/training/basics/actionbar/styling.html
Chapter on Styling the action bar

I receive an error which I can't work out the origin of. The error is on this line of code

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

error: Error: No resource found that matches the given name (at 'theme' with value '@style/CustomActionBarTheme'). Could anybody explain why this line throws an error?

Code: 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>

Code: 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>
user2445971
  • 77
  • 1
  • 11
  • http://stackoverflow.com/questions/20516245/how-to-put-background-colour-for-action-bar-in-android/20516289#20516289. what is the error?. Move it to `styles.xml` – Raghunandan Dec 12 '13 at 09:07
  • Hi error: Error: No resource found that matches the given name (at 'theme' with value '@style/CustomActionBarTheme'). at Android Manifest.xml android:theme="@style/CustomActionBarTheme" – user2445971 Dec 12 '13 at 09:10
  • Hi When I do that: I get a new error error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.Holo.Light.DarkActionBar'. please advise – user2445971 Dec 12 '13 at 09:13
  • no need for the change its the same. http://developer.android.com/guide/topics/ui/themes.html. – Raghunandan Dec 12 '13 at 09:14
  • use `"@android:style/Theme.Holo.Light.DarkActionBar` and no need for change. http://stackoverflow.com/questions/18370816/no-resource-found-that-matches-the-given-name-style-theme-holo-light-darkacti – Raghunandan Dec 12 '13 at 09:22

0 Answers0