Android: set color programatically from XML color constants
Color entries should be like this
<color name="tableHead">#FF444444</color>
and use tv.setBackgroundResource(R.color.tableHead);
Use,..
Color.parseColor("#bdbdbd");
like,
mTextView.setTextColor(Color.parseColor("#bdbdbd"));
OR......................
Get a handle to the root layout used, then set the background color on that. The root layout is whatever you called setContentView with.
// Now get a handle to any View contained // within the main layout you are using
View someView = findViewById(R.id.randomViewInMainLayout);
// Find the root view
View root = someView.getRootView()
// Set the color
root.setBackgroundColor(getResources().getColor(android.R.color.red));
tv.setTextColor(getResources().getColor(R.color.tableHead));
And guess what your colors.xml should be like this
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="tableHead">#FF444444</color>
</resources>