Up and Down states for buttons


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.