title: How to change a TextView's background color with a color defined in my values/colors.xml file?
body: <p>I am working on an Android project using Eclipse. I want to change the background color of a TextView using one of the colors I've defined in res/values/colors.xml. These colors are all available by using R.color.color_name.</p>
  
  <p>My problem is that this simply won't work. Changing to one of my defined colors always leaves the TextView's background set to its default color, in this case, black. If I use one of Java's built-in colors, it works fine. I'm thinking it's a color definition problem, something involving how I actually define my colors in my XML, but I'm not sure.</p>
  
  <pre><code>// This works:
  weight1.setBackgroundColor(Color.BLACK);
  
  // This does not work:
  weight2.setBackgroundColor(R.color.darkgrey);
  
  // Color Definition: (this is in a separate xml file, not in my Java code)
  &lt;color name = "darkgrey"&gt;#A9A9A9&lt;/color&gt;
  </code></pre>