Change background color in Android action bar, basic tutorial

I am trying to change the color of the ActionBar of a new Android application made by the Eclipse wizard, after the Android tutorial ( here ), but I had some problems.

I set minSdkVersion to 10 (it should be android 2.1 or so).

When I embed this code in theme.xml (as stated in the lesson):

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

        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/AppTheme">
        <item name="android:background">#FFFFFF</item>

        <!-- Support library compatibility -->
        <item name="background">#FFFFFF</item>
    </style>
</resources>

Eclipse give me these errors:

  • line 5: android: actionBarStyle requires API level 11 (current min is 10)
  • line 8: error: error: no resource was found matching the specified name: attr 'actionBarStyle'.
  • line 16: error: error: resource not found which matches the specified name: attr 'background'.

I changed the little things (base theme and color), however the clean code is in the tutorial.

My Styles.xml :   

    <!--
        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>

?

+4

All Articles