title: Trying to change main activity background color on button click
body: <p>Here's my main:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_menu);
  
      Button btn = (Button) findViewById(R.id.newgame_button);
  
      btn.setOnClickListener(new View.OnClickListener() 
      {
          @Override
          public void onClick(View v) {
              changeBackground(v);
          }
      }); 
  }
  </code></pre>
  
  <p>I've tried the follow methods, both of which have failed:</p>
  
  <pre><code>public void changeBackground(View v) 
  {
        View someView = findViewById(R.id.main);
        View root = someView.getRootView();
        root.setBackgroundColor(getResources().getColor(R.color.red));
  }
  
  public void changeBackground(View v) 
  {
        View root = v.getRootView();
        root.setBackgroundColor(getResources().getColor(R.color.red));
  }
  </code></pre>
  
  <p>I searched and found the solution for how to solve this in <a href="https://stackoverflow.com/questions/4761686/how-to-set-background-color-of-activity-to-white-programmatically">How to set background color of Activity to white programmatically?</a>; the solution posted was:</p>
  
  <pre><code>  // 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(android.R.color.red);
  </code></pre>
  
  <p>When I try <code>android.R.color.red</code>, eclipse tells me that it should be in the form in my examples.</p>
  
  <p>I did manage to change the background of my button with:</p>
  
  <pre><code>public void changeBackground(View v) 
  {
      v.setBackgroundColor(getResources().getColor(R.color.red));
  }
  </code></pre>
  
  <p>So, I'm pretty confident that the issue is not with: <code>getResources().getColor(R.color.red)</code>.  I've tried many different ways, and I'm not getting anywhere.  For reference, here's my xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" 
      android:background="@color/LightCyan"
      android:id="@+id/main"&gt;
  
     &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="0dip"
          android:text="@string/welcome"
          android:gravity="center"
          android:layout_weight="3" /&gt;
  
     &lt;LinearLayout
          android:layout_width="200dp"
          android:layout_height="0dip"
          android:orientation="vertical"
          android:layout_gravity="center"
          android:layout_weight="2" &gt; 
  
         &lt;Button
             android:id="@+id/resume_button"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:text="@string/resume" 
             android:background="@color/Plum"/&gt;
  
         &lt;Button
             android:id="@+id/newgame_button"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:text="@string/new_game"
             android:background="@color/Plum" 
             android:onClick="changeBackground"/&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>Any help would be appreciated.  Thanks in advance.</p>