Android issue with custom 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 try to implement a custom theme in 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 get erros indicating

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

+4
source share
3 answers

You should write android: in front of the style, namely @android:style/Theme.Holo.Light.DarkActionBar .

+6
source

They did not include examples of all the files used or how they made files or what files should be created.

It seems that in addition, they forgot to use @android, they did not mention that files, for example actionbar_background.xml, should be created under res / drawable / in this case, or that theme.xml should be created under res / values ​​/

They seem to have created styles (for images in the manual) using:
http://jgilfelt.imtqy.com/android-actionbarstylegenerator/

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

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

From the question I asked, I assume they used the Android Developer Guide .

+2
source

you can add theme.xml to styles.xml

0
source

Source: https://habr.com/ru/post/1501773/


All Articles