Title: Changing Layout Background Colors in Java
Tags: java;android;xml;layout;background
Question: I recently made an app with several XML layouts (and I gave them all very colorful backgrounds too!)  However, my friend noted it was a little 'too' colorful.
So, I decided to add a checkbox to the main.xml file, which is checked by default.  If unchecked, I want every background color to go black, my buttons' colors to change their background color from "@drawable/buttoncolor" to "@drawable/colorless", and all the text in the buttons to change to white ("#FFFFFF").  Then if checked again, the program should restore to default.
So the question is... how would I do this?  I already established something like this:
View colorBox = findViewById(R.id.noColor);
colorBox.setOnClickListener(this);
where colorBox is my checkbox.
And later on...
public void onClick(View v) {
switch (v.getId()) {
// (Other code I have here)
case R.id.noColor:
// Does something go here..?
break;
All help is appreciated.
(On a side note, this solution didn't work for me either: How to change a TextView&#39;s background color with a color defined in my values/colors.xml file?)

Here is the accepted answer: colorBox.setBackgroundResource(R.drawable.colorless);
((TextView)colorBox).setTextColor(COLOR.WHITE);
you need to import java.awt.Color
Comment for this answer: findViewById(R.id.layout).setBackgroundColor(Color.BLACK)
but obviously replace R.id.layout with the id you've given your layout
Comment for this answer: Thanks, that works for the textboxes.  How do I change a whole layout's background to black though?

Here is another answer: Look for setBackgroundResource or setBackgroundDrawable and then call either of these methods on each view to change there background.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:07/21/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><android><xml><layout><background>', 'Title': 'Changing Layout Background Colors in Java', 'ViewCount': 2529, 'id': 6776392, 'user_AboutMe': '<p>Open source enthusiast with interests in Android application development, machine learning, and data mining.</p>\n', 'user_AccountId': 443066.0, 'user_DisplayName': 'Mxyk', 'user_Reputation': 10590.0, 'user_Views': 1632.0, 'user_id': 834063.0}}