Theme based on version

barx

Well-Known Member
Licensed User
Longtime User
I'm trying to apply android themes based upon sdk version. This should be a relatively easy task but I keep getting errors

Code: Copy
Generating R file.                      Error
AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/MyTheme').
AndroidManifest.xml:19: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/MyThemeNoTitle').
AndroidManifest.xml:32: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/MyThemeTransparent').
AndroidManifest.xml:40: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/MyThemeTransparent').
AndroidManifest.xml:55: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/MyThemeTransparent').

So, I'm obviously doing something wrong, but cannot see where I'm wrong

What I have is:

Manifest

Code: Copy
SetActivityAttribute(Person, android:theme, @android:style/MyThemeTransparent)
SetActivityAttribute(Present, android:theme, @android:style/MyThemeTransparent)
SetActivityAttribute(EventDetail, android:theme, @android:style/MyThemeTransparent)
SetActivityAttribute(Main, android:theme, @android:style/MyThemeNoTitle)
SetApplicationAttribute(android:theme, @android:style/MyTheme)

Then I created a 'read-only' file system

res/values/theme.xml

Code: Copy
<?xml version="1.0" encoding="utf-8"?>

<resources>
    <style 
        name="MyTheme" parent="android:style/Theme.Light"> 'Also tried with @'s. i.e @android:style/Theme.Light
    </style>

    <style 
        name="MyThemeNoTitle" parent="android:style/Theme.Light.NoTitleBar">
    </style>

    <style 
        name="MyThemeTransparent" parent="android:style/Theme.Translucent.NoTitleBar">
    </style>
</resources>

res/values-v11/theme.xml

Code: Copy
<?xml version="1.0" encoding="utf-8"?>

<resources>
    <style 
        name="MyTheme" parent="@android:style/Theme.Holo.Light">
    </style>

    <style 
        name="MyThemeNoTitle" parent="@android:style/Theme.Holo.Light.NoActionBar">
    </style>

    <style 
        name="MyThemeTransparent" parent="@android:style/Theme.Holo.Light.Panel">
    </style>
</resources>

Can anybody see where I have gone wrong, I've read it over and over again but cannot see it.

Thanks
 
p.s. I have cleaned the project multiple times. It's now sparkling ;)
 
Upvote 0
Just been made aware i posted this in tuts not questions. Sorry, was rushing. Please move to questions.
 
Upvote 0
Just to keep this thread updated...
We found a solution for barx's problem in the B4A chatroom (yes some of us still hang out there lols).

The custom theme (resource) was not being found as it was being declared incorrectly:
Code: Copy
SetActivityAttribute(Person, android:theme, @android:style/MyThemeTransparent)

That actually references a non-existent built in android theme - hence the theme is not found.
The correct syntax is:

Code: Copy
SetActivityAttribute(Person, android:theme, @style/MyThemeTransparent)

@android:style changed to @style
It now correcty references barx's custom theme.

Martin.
 
Upvote 0
Thanks again warwound (Martin) a classic example of the use of the chat room. batting ideas around. Now works perfect and a tutorial explaining what the use of this is will hopefully follow in the next few days once I get a few minutes spare.
 
Upvote 0
Back
Top