misguided
misguided

Reputation: 3789

Android issue with implementing customised themes

My android project

AndoidManifest.xml has

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/CustomActionBarTheme" >
        <activity
            android:name="com.example.myfirstapp.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.myfirstapp.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>

When I am trying to implement a customised theme under res\values\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>

I am getting erros specifying

Error retrieving parent for item: No resource found that matches the given name '@style/Theme.Holo.Light.DarkActionBar'. and Error retrieving parent for item: No resource found that matches the given name '@style/ Widget.Holo.Light.ActionBar.Solid.Inverse'.

Upvotes: 4

Views: 2994

Answers (3)

Kkloe
Kkloe

Reputation: 199

They have not included examples of all the files used or how they made the files or that files needs to be created.

It seems that beside that they have forgotten the use of @android they didn't mention that files like actionbar_background.xml have to be created under res/drawable/ in this case or that themes.xml should be created under res/values/

They seem to have created the styles(for the pictures in the guide) using:
http://jgilfelt.github.io/android-actionbarstylegenerator/

And files generated themselves following:
http://developer.android.com/guide/topics/resources/drawable-resource.html

They do the same things in the rest of the chapter. The guide is quite confusing when you are new.

From the question asked I assume that they have used the guide at android developers.

Upvotes: 2

Digit
Digit

Reputation: 1939

you can add themes.xml into styles.xml

Upvotes: 0

Yuichi Araki
Yuichi Araki

Reputation: 3458

You have to write android: before style, namely @android:style/Theme.Holo.Light.DarkActionBar.

Upvotes: 6

Related Questions