Hello dear Android developers !

In my app, users can choose between two themes at startup. However,
I've some problems overriding the android:textColor property using
themes.

I want to be able to change the text color (basically to white/black)
of some textview, but only these. I'm trying to do that this way:

attrs.xml:
<attr name="foregroundColor" format="reference" />

themes.xml:
        <style name="Light" parent="android:Theme.Light">
                <item 
name="foregroundColor">@color/main_message_color_light</item>
        </style>

        <style name="Dark" parent="android:Theme">
                <item 
name="foregroundColor">@color/main_message_color_dark</item>
        </style>

main_message_color_light.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android";>
  <item android:state_enabled="false" android:color="#80ffffff"/>
  <item android:color="#ffffffff"/>
</selector>

On my textview, I'm doing ' android:textColor="?foregroundColor" '. My
application foreclose with this error :

"ERROR/AndroidRuntime(958): Caused by: android.content.res.Resources
$NotFoundException: Resource is not a ColorStateList (color or path):
TypedValue{t=0x2/d=0x7f01000a a=-1}"

If I replace the reference to @color/ by a hard coded color, same
error.

How can I easily set textColor with theme ?

Many thanks for your time

Seb

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to