I am following the android training , in styling the Action bar.
I am facing error because of android:theme=@style/MyActionBar
.
I want to know how to style the action bar.
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyActionBar" >
IllegalStateException: You need to use a Theme.AppCompat theme with this activity
I thought the error from :
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
so I modify it to
<style name="CustomActionBarTheme"
parent="@android:style/Theme.AppCompat.Light ">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
I had the following error :
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light '.
I created a new file as the training explained
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#aaaaaa</item>
</style>
</resources>
And here is the manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyActionBar" >
<activity
android:name="com.example.helloworld.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.helloworld.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.Helloworld.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.Helloworld.MyActivity" />
</activity>
</application>
</manifest>