title: View.OnClickListener() in Android responding for the wrong button
body: <p>I am having an issue registering a call when a button is clicked.</p>
  
  <p>I have 2 EditTexts, one Button and one CheckBox. I would like to get the onClick() function called when the Button is pressed. Unfortunately, it only happens when the CheckBox is pressed, but it's not the correct ID so I am confused.</p>
  
  <p>Here is the java code:</p>
  
  <pre><code>Button connect = (Button) findViewById(R.id.connectToServer);
  connect.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
      ....
  }
  </code></pre>
  
  <p>As you can see, I look for the id "connectToServer".</p>
  
  <p>This is my .xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content" android:background="#ffb6b6b6"
          android:textColor="#ffffffff" android:padding="2px" android:text="Settings" /&gt;
      &lt;LinearLayout android:orientation="vertical"
          android:layout_width="fill_parent" android:layout_height="wrap_content"
          android:padding="13px"&gt;
          &lt;TextView android:layout_width="fill_parent"
              android:layout_height="wrap_content" android:textSize="25px"
              android:textColor="#ffffffff" android:text="Set server settings" /&gt;
  
          &lt;TableLayout android:layout_marginTop="10px"
              android:stretchColumns="1" android:layout_width="fill_parent"
              android:layout_height="wrap_content"&gt;
              &lt;TableRow&gt;
                  &lt;TextView android:text="IP address:" /&gt;
  
                  &lt;EditText android:id="@+id/serverIP" android:maxLength="15" /&gt;
              &lt;/TableRow&gt;
  
              &lt;TableRow&gt;
                  &lt;TextView android:layout_marginTop="4px" android:text="Port:" /&gt;
                  &lt;EditText android:id="@+id/serverPort" android:maxLength="15" /&gt;
              &lt;/TableRow&gt;
  
          &lt;/TableLayout&gt;
  
          &lt;LinearLayout android:layout_width="fill_parent"
              android:layout_marginTop="10px" android:orientation="horizontal"
              android:layout_height="fill_parent" android:gravity="center"&gt;
              &lt;Button android:text="Connect" android:id="@+id/connectToServer"
                  android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  
      &lt;TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content" android:background="#ffb6b6b6"
          android:textColor="#ffffffff" android:padding="2px"
          android:layout_marginTop="10px" android:text="Availability" /&gt;
      &lt;LinearLayout android:orientation="vertical"
          android:layout_width="fill_parent" android:layout_height="wrap_content"
          android:padding="13px"&gt;
          &lt;TextView android:layout_width="fill_parent"
              android:layout_height="wrap_content" android:textSize="25px"
              android:textColor="#ffffffff" android:text="Set device available" /&gt;
  
          &lt;TableLayout android:layout_width="fill_parent"
              android:layout_height="wrap_content" android:layout_weight="1"&gt;
              &lt;TableRow&gt;
                  &lt;TextView android:layout_marginTop="10px"
                      android:layout_width="wrap_content" android:layout_height="fill_parent"
                      android:layout_weight="1"
                      android:text="Uncheck to disallow anyone from\nremotely connecting to the device." /&gt;
                  &lt;CheckBox android:id="@+id/checkbox" android:gravity="right"
                      android:checked="true" android:layout_weight="1"
                      android:layout_width="wrap_content" android:layout_height="fill_parent" /&gt;
              &lt;/TableRow&gt;
          &lt;/TableLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The important line I believe would be this:</p>
  
  <pre><code>&lt;Button android:text="Connect" android:id="@+id/connectToServer"
      android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt;
  </code></pre>
  
  <p>but the code only gets called when the CheckBox button is checked or unchecked. I am not sure why that is.</p>
  
  <p>Thank you very much!</p>