0

I am having this two array; one is Int type and another is string type:

int[] COLOURS = { Color.CYAN, Color.BLUE, Color.GREEN, Color.YELLOW,
        Color.MAGENTA, Color.RED };

String[] color = { "#ff0000","#ff0f00" ,"#ffff00"};

I am using this code to set color from the Integer array to the background of a view according to value of progress:

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
        boolean fromUser) {
    full_page.setBackgroundColor(COLOURS[progress]);

}

But I need to set color from the string array, from this one:

String[] color = { "#ff0000","#ff0f00" ,"#ffff00"};

but this is showing error in my code.

0

2 Answers 2

1

like

full_page.setBackgroundColor(Color.parseColor(COLOURS[progress]));

i hope its useful to you

Sign up to request clarification or add additional context in comments.

Comments

1

You have to convert the string to Color like

   Color.parseColor("#ff0000");

In Your case for example:

   Color colOne = Color.parse(color[0]);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.