1

I'm trying to learn how to develop in Android and I'm following this tutorial: https://developer.android.com/training/basics/actionbar/styling.html

Right now, I'm trying to set the background of an action bar to orange. The tutorial gives the following code (note that I'm developing with Android 2.1 compatibility so I'm using the AppCompat stuff and so on)

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

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

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

        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>
    </style>
</resources>

where my actionbar_background.xml file is:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#FFA500" />
</shape>

My problem is that I get the following error: android:actionBarStyle requires API level 11 (current min is 8) in the line where I added the comment <!-- error here -->.

The solution I found is to delete that line. Also because it looks like it is exactly the same thing that the line below is doing (except that the 'android:' namespace is not explicitly stated). Everything seems to work now...

I'd like to know if this is a mistake in the tutorial's code (i.e. I was right to delete the line) or if I have some other kind of problem... any idea? Thanks!

EDIT

the following post addresses the same problem: Android AppCompat requires API level 11.

It seems like it is indeed an error in the tutorial itself. It's still unclear to me, though, why the problem happens in the android namespace (should specifically concern API>14) and not in the default one (should address any other API).

Community
  • 1
  • 1
PLB
  • 881
  • 7
  • 20

0 Answers0