Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android issue with implementing customised themes

Tags:

android

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'.

like image 288
misguided Avatar asked Feb 16 '23 07:02

misguided


2 Answers

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

like image 56
Yuichi Araki Avatar answered Feb 17 '23 21:02

Yuichi Araki


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.

like image 45
Kkloe Avatar answered Feb 17 '23 20:02

Kkloe