title: Why cant i set the onTouchListener for my RelativeLayout?
body: <p>I am trying to make a basic app in which you touch the screen and it changes the background color of the screen.  However I can't set the OnTouchListener for the RelativeLayout that is containing my app essentials.  The app throws an error upon building and then crashes, not sure whats going on here =/  If anyone could help that would be great =)</p>
  
  <p>Java Code:</p>
  
  <pre><code>public class ColorCrazeActivity extends AppCompatActivity{
  
  int pointCount = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      RelativeLayout myLayout = (RelativeLayout) findViewById(R.id.myRelativeLayout1);
      myLayout.setOnTouchListener(
              new RelativeLayout.OnTouchListener() {
                  public boolean onTouch(View v, MotionEvent m) {
                      if (m.getActionMasked() == MotionEvent.ACTION_DOWN) {
                          changeColor();
                      }
  
                      return true;
                  }
              }
      );
  
      setContentView(myLayout);
  }
  
  public void changeColor(){
      int myNum1 = (int)Math.floor(Math.random() * (255));
      int myNum2 = (int)Math.floor(Math.random() * (255));
      int myNum3 = (int)Math.floor(Math.random() * (255));
  
      TextView myTextView = (TextView)findViewById(R.id.myTextView);
  
      RelativeLayout myRelativeLayout = (RelativeLayout)findViewById(R.id.myRelativeLayout1);
  
      myTextView.setText("RGB(" + Integer.toString(myNum1) + ", " + Integer.toString(myNum2) + ", " + Integer.toString(myNum3) + ")");
      myRelativeLayout.setBackgroundColor(Color.argb(255, myNum1, myNum2, myNum3));
      addPoints();
  }
  
  public void addPoints(){
      pointCount += 1;
  
      TextView myTextView1 = (TextView)findViewById(R.id.myTextView1);
      myTextView1.setText(Integer.toString(pointCount));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>XML Code:</p>
  
  <pre><code>&lt;RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:id="@+id/myRelativeLayout"
  tools:context="com.toymakersdev.colorcraze.ColorCrazeActivity"
  android:focusableInTouchMode="true"
  android:background="#000c65"&gt;
  
  
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:layout_alignParentEnd="true"
      android:id="@+id/myRelativeLayout1"
      android:clickable="true"
      android:focusable="true"
      android:focusableInTouchMode="true"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/myTextView1"
          android:text="Taps: 0"
          android:textSize="40dp"
          android:textColor="#ffffff"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/myTextView"
          android:text="Tap here"
          android:textSize="50dp"
          android:textAlignment="center"
          android:textColor="#ffffff"
          android:layout_centerVertical="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have a RelativeLayout nested inside of another RelativeLayout because i thought the error was because it was the root view originally.  Apparently not considering its still throwing the error.</p>