5

I'm building a selector for button, with a state list drawable,

  states.addState(new int[] {android.R.attr.state_checked},
                               checkedDrawable.getDrawable());

    states.addState(new int[] {},
                               unCheckDrawable.getDrawable());

What should I put in second state ? there is no android.R.attr.state_unchecked

Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141

1 Answers1

11

This question might help you.

It says, that you should use the negative of the state you need. So in your case it should be:

states.addState(new int[] {-android.R.attr.state_checked}, unCheckDrawable.getDrawable());
Community
  • 1
  • 1
Tim Roes
  • 1,406
  • 1
  • 12
  • 22