This is my code to convert a String to Color:
public Color prepareColour(String str) {
str.replace("#", "");
float r = Float.valueOf(str.substring(0,1));
float g = Float.valueOf(str.substring(2,3));
float b = Float.valueOf(str.substring(4,5));
Color color = Color.valueOf(r,g,b);
return color;
}
I get the following debug error:
Error:(16, 23) error: constructor Color in class Color cannot be applied to given types; required: no arguments found: float,float,float reason: actual and formal argument lists differ in length
However, the suggestion before compiling from Android Studio is:
Call requires API level 26 (current min is 17) ......
I see there are answers from 2011 supporting this way of creating a Color, so surely it works on API 17 and doesn't require 26.
I have tried cleaning and rebuilding the project, as well as replacing the str.substring
with actual values and nothing changes.
Why will the code not compile?