Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final int[] colors = {Color.parseColor("#008DCD"), Color.parseColor("#FFFF5722")}; // Define as cores que serão alternadas
- button.setOnClickListener(new View.OnClickListener() {
- int i = 0;
- @Override
- public void onClick(View v) {
- Button button = (Button) v;
- GradientDrawable gd = new GradientDrawable();
- gd.setCornerRadius(38);
- gd.setColor(colors[i % 2]); // Alterna entre as duas cores definidas
- button.setBackground(gd);
- i++;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement