Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button btn = (Button) findViewById(R.id.button);
- Bitmap pressBmp = BitmapFactory.decodeResource(getResources(), R.drawable.press);
- Bitmap checkBmp = BitmapFactory.decodeResource(getResources(), R.drawable.check);
- Bitmap normalBmp = BitmapFactory.decodeResource(getResources(), R.drawable.normal);
- Drawable pressDraw = new BitmapDrawable(getResources(), pressBmp);
- Drawable checkDraw = new BitmapDrawable(getResources(), checkBmp);
- Drawable normalDraw = new BitmapDrawable(getResources(), normalBmp);
- StateListDrawable drawable = new StateListDrawable();
- drawable.addState(new int[]{android.R.attr.state_pressed}, pressDraw);
- drawable.addState(new int[]{android.R.attr.state_selected}, checkDraw);
- drawable.addState(new int[]{}, normalDraw);
- btn.setBackground(drawable);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement