Android: actionBarStyle requires API level 11
When using ActionBarSherlock in xml at:
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> I got this error:
android:actionBarStyle requires API level 11 (current min is 8) error I use it to reverse port my application using the action bar to 2.2 devices.
How to use them together:
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> You should use only:
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> since you may get an error, you have android:actionBarStyle , available at API level 11.
If you want the ActionBar style ActionBar look the same at all API levels, you need to create different folders for the selected API level and create new style.xml / themes.xml in these folders.
For example:
- res -- values -- styles.xml -- themes.xml // API LEVEL 8+ -- values-v11 -- styles.xml -- themes.xml // API LEVEL 11+ -- values-v14 -- styles.xml -- themes.xml // API LEVEL 14+ The second thing I can think of is to be careful what topics you include in your current at different API levels.
For example, for API level 8: you will use @style/Theme.Sherlock.Light.DarkActionBar and you only have to use actionBarStyle . When styling the action bar for API level 14+, you donβt need an actionBarStyle , because you probably set the Holo.Light theme as the parent for your current one, so in this situation you have to use android:actionBarStyle .
Another option is to use the tools:targetApi , which requires the tools namespace. This acts similarly to the @TargetApi annotation, which you can use in java files.
<resources xmlns:tools="http://schemas.android.com/tools"> <style name="MyThemes.MyTheme"> <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle" tools:targetApi="11">@style/Widget.Styled.ActionBar</item> </style> </resources> Pay attention to xmlns:tools="http://schemas.android.com/tools" in the <resources> tag as required.
You can simply select the errors in Eclipse and press the "Delete" key. Then just run the project and it will work.
You delete the abstracts each time you modify your XML.
It depends on which version of the SDK you want to configure:
Targets below 11:
On your AndroidManifest.xml use:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="x" android:maxSdkVersion="10"/> x anything between 8-10 (depends on your code)
In your style, use:
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> Set up any device:
On your AndroidManifest.xml use:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /> 16 used in ActionBarSherlock can be any greater than or equal to 11 (depending on your code)
In your style, use both:
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> The first one is for an ActionBarSherlock theme, and the second is for using the same theme on Android devices that already support ActionBar
Edit: Clear Lint warnings (red underline in the XML file that may be displayed):
