1

the background of a button is set based on selectors defined as:

 <selector xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true">
      <item android:state_checked="true" android:drawable="@drawable/checked" />
      <item android:state_focused="true" android:drawable="@drawable/focused" />
      <item android:drawable="@drawable/normal"/>
   </selector>

How do I define the button's text color based on its state (pressed / focused)? This doesn't work:

    <selector xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true">
      <item android:state_checked="true" android:drawable="@drawable/checked" android:textColor="#CCCCCCCC"/>
   </selector>
Herr K
  • 1,751
  • 3
  • 16
  • 24
  • i think this post explains your problem http://stackoverflow.com/questions/3882064/how-to-change-color-of-button-in-android-when-clicked – LostMohican Oct 05 '11 at 14:18
  • @LostMohican: MMhh, not really. I could set the stuff programmatically, but I'd rather prefer the "xml-way" – Herr K Oct 06 '11 at 05:12
  • Were you ever able to figure out how to define the button's text color based on state? – David Wasser Feb 12 '13 at 17:36

0 Answers0