Hi, I'm trying to set a get a ColorStateList object from a xml file
and setting it to a TextView textColor but I can't get it to work.

Code:

------------
ColorStateList csl = null;

                 XmlResourceParser xpp=Resources.getSystem().getXml
                 (R.color.selector_txt);
                     try {
                                csl = 
ColorStateList.createFromXml(getResources(), xpp);
                        } catch (XmlPullParserException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }

                 final TextView tv = (TextView) findViewById(R.id.label);
                 tv.setTextColor(csl);
------------

in res/color/sector_txt.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android";>
   <item android:state_pressed="true" android:textColor="#FF004F79"/>
   <item android:state_pressed="false" android:textColor="#FF19AEFF"/>
 </selector>

------------

The TextVew comes from my layout xml of a ListView Im using it in.
When I use the above code my app crashes.

How to I use the ColorStateList?
Have I set it correctly?
Where do I find the different states I can use in the xml?

thanks
/Micke
--~--~---------~--~----~------------~-------~--~----~
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