I need to convert a color integer value back to text? For example, look at this imaginative code
int myColor = -16777216; //int value for Color.BLACK
convertColorToText(myColor);
The method would return string with value “BLACK”.
Is this possible and how to do it?
UPDATE
My app uses a Color Picker (code.google.com/p/android-color-picker) and I want to notify user which color has he chosen. For example, he chooses a black color, clicks OK button, and sees a Toast saying “You have chosen Black color”.
I don’t think you can do it out-of-the-box, best what you can do is to build a map or list of known colors (for example using ‘red’, ‘blue’, ‘green’, ‘black’, ‘white’, ‘gray’, ‘cyan’, ‘magenta’, ‘yellow’, ‘lightgray’, ‘darkgray’ -> standard android colors understood by parseColor method http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
And then you could find it by lookup and either exact match (but the usefulness of this would be limited) or finding the CLOSEST color. You can find out about a good and simplest algorithm of finding best match here, for example: Best algorithm for matching colours.