Posted By

cruddell001 on 12/09/13


Versions (?)

Up and Down states for buttons

 / Published in: Java

  1. //set up (normal) and down (pressed) states for a button
  2. Drawable imageUp = null;
  3. Drawable imageDown = null;
  4. //set Drawable images here
  5. StateListDrawable stateListDrawable = new StateListDrawable();
  6. stateListDrawable.addState(new int[] {android.R.attr.state_pressed},imageDown);
  7. stateListDrawable.addState(StateSet.WILD_CARD, imageUp);
  8. theButton.setBackgroundDrawable(stateListDrawable);

Report this snippet  

You need to login to post a comment.