java - How I change the colors of my buttons between one array colors? -
i'm trying change colors of buttons 1 array colors pre-defined. this:
string[] colors = {"#2962ff", "#00bfa5", "#ff6d00", "#aa00ff"}; random random = new random(); string myrandstring = random.nextint(colors.length); // buttons ingridlayout00.setbackgroundcolor(myrandstring); ingridlayout01.setbackgroundcolor(myrandstring); ingridlayout10.setbackgroundcolor(myrandstring); ingridlayout11.setbackgroundcolor(myrandstring);
but don't know how fix this.
you doing great need pass random number array , color random index number
int[] colors = {#2962ff, #00bfa5, #ff6d00, #aa00ff}; random random = new random(); int myrandstring = random.nextint(colors.length); // buttons ingridlayout00.setbackgroundcolor(color.parsecolor(colors[myrandstring])); ingridlayout01.setbackgroundcolor(color.parsecolor(colors[myrandstring])); ingridlayout10.setbackgroundcolor(color.parsecolor(colors[myrandstring])); ingridlayout11.setbackgroundcolor(color.parsecolor(colors[myrandstring]));
all have
setbackgroundcolor(colors[myrandstring]);
which gets color random index number
Comments
Post a Comment