title: Android: checkbox.isChecked() is always returning a false condition
body: <p>I'm trying to code a checkbox into a help screen which is essentially a pop up view (an activity that's started by the main program) containing a ScrollView that has the help text, and OK button, and a checkbox that asks if you want the help screen to appear automatically at program start. Everything displays properly on the screen, and the checkbox toggles, when touched. However, when OK is pressed, and I test the state of the checkbox with .isChecked() I'm always getting a false. I'm sure it's something simple I've missed. XML file follows follows:</p>
  
  <p>helpdialog.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent" android:layout_height="wrap_content"
   android:background="#ffffff"&gt;
  
   &lt;ScrollView android:id="@+id/ScrollView01"
   android:layout_width="wrap_content" android:layout_below="@+id/ImageView01"
   android:layout_height="300px"&gt;
  
   &lt;TextView android:text="@+id/helpView" android:id="@+id/helpView"
   android:layout_width="wrap_content" android:layout_height="wrap_content"
   android:textColor="#000000"/&gt;
  
  &lt;/ScrollView&gt;
  &lt;Button android:id="@+id/Button01" 
  android:layout_width="wrap_content" android:layout_height="wrap_content"
  android:layout_centerHorizontal="true" android:text="  OK  "
  android:layout_below="@id/ScrollView01"/&gt;
  
  &lt;CheckBox android:id="@+id/chkNoHelp" android:textColor="#000000"
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" android:text="Don't Display at Startup"
  android:layout_below="@id/Button01"        /&gt;  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>HelpBox.java:</p>
  
  <pre><code>public class HelpBox extends Activity {
  
  CheckBox checkBox;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
       //set up dialog
      Dialog dialog = new Dialog(this);
      dialog.setContentView(R.layout.helpdialog);
      dialog.setTitle("Help");
      dialog.setCancelable(true);
  
      //set up text
      TextView text = (TextView) dialog.findViewById(R.id.helpView);
      text.setText(getString(R.string.help_text));
  
      //set up button
      Button button = (Button) dialog.findViewById(R.id.Button01);
      button.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              Boolean mDisplayHelp;
  
              setContentView(R.layout.helpdialog);
  
              checkBox = (CheckBox) findViewById(R.id.chkNoHelp);
              if (checkBox.isChecked()) {
                  mDisplayHelp = true;
              } else {
                  mDisplayHelp = false;
              }
              finish();
          }
      });
      //now that the dialog is set up, it's time to show it    
      dialog.show();
  }
  }
  </code></pre>
  
  <p>Setting breakpoints on both "mDisplayHelp" lines always breaks at the 'false' branch regardless of whether the check box displays a green check or not when the OK button is pressed.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit (10/10):</p>
  
  <p>Its clear what I want to do is pick up information after the user exits the dialog, so I can sense the state of the checkbox and store it as a preference. For this I assume I have to test it in onDestory. So, I did that:</p>
  
  <pre><code>@Override
  public void onDestroy() {
      Boolean mDisplayHelp;
  
      setContentView(R.layout.helpdialog);        
      checkBox = (CheckBox) findViewById(R.id.chkNoHelp);
      if (checkBox.isChecked()) {
          mDisplayHelp = true;
      } else {
          mDisplayHelp = false;
      }
  
  }
  </code></pre>
  
  <p>However, I'm still always coming up with FALSE as a result, regardless of whether the checkbox is display checked or off. In this instance, if I don;t include the setContentView, I get a NullPointerException on the isChecked.</p>