I am working on an Android project using Eclipse. I want to change the background color of a TextView using one of the colors that I defined in res / values ββ/colors.xml. All of these colors are available using R.color.color_name.
My problem is that it just won't work. Switching to one of my defined colors always leaves the TextView's background color equal to its default color, in this case black. If I use one of the built-in Java colors, it works fine. I think this is a color definition problem, which is related to the way I actually define my colors in my XML, but I'm not sure.
// 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) <color name = "darkgrey">
android textview
Phil ringsmuth
source share