android - Retrieving color programmatically from R.color returns wrong colors -


i trying take color names listed in user's xml file , return hexadecimal color. using code based off post retrieve color programmatically r.color. know close because when had small set of colors in hash map names keys working, on 300 colors in file , looking 5 or 6 seems wasted processing time. code below being worked with, can include more if needed.

example of user's xml file.

<item>     <item_name>daily</item_name>     <price>400</price>     <type>entry</type>     <color>green</color> </item> 

colors.xml

 <color name="green">#008000</color> 

java:

 0   **pass in name method call**  1   class res = r.color.class;  2   field field = res.getfield( name );  3   color = field.getint(null); 

when run debug results given follows:

0: name = "green" 1: res = tech.travis.poolpos.r$color 2: field = public static final int tech.travis.poolpos.r$color.green 3: color = 2131099743 (integer).  translates #&5f00067f,      navy blue opacity of 37%. 

the integer should returned green should -16744448, not 2131099743.

how, if possible, take name string , match , return color listed in colors.xml?

that id of colour, not colour itself. colour need getresources().getcolor(field.getint(null)); instead.

everything on r id. why have methods getcolor or getdrawable take argument r.color.my_color or r.drawable.my_drawable.