title: Display texts of a checkbox on AlertDialogue
body: <p>I want to display the text on the AlertDialogue (e.g. "Sports") from a checkbox when it is checked, along with the name, email and date of birth message. When the name and email and date is set, An AlertDialogue shows what i have typed in or set. I want it to show also which checkbox's i have checked</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>package com.example.com.forminput;
  
  import android.annotation.TargetApi;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.database.sqlite.SQLiteException;
  import android.os.Build;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.CheckBox;
  import android.widget.DatePicker;
  import android.widget.EditText;
  import android.widget.Toast;
  import android.widget.CompoundButton;
  
  
  public class DataInput extends Activity {
  
  
      @TargetApi(Build.VERSION_CODES.HONEYCOMB)
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_data_input);
  
          final DatePicker dp = (DatePicker) this.findViewById(R.id.DatePickerDOB);
          dp.setCalendarViewShown(false);
          dp.init(1980, 5, 1, null); // set to 1st June 1980 - note months start at 0
  
          Button btnNext = (Button) findViewById(R.id.ButtonNext);
          Button btnClear = (Button) findViewById(R.id.ButtonClear);
  
  
    /* Handle the event generated when the user clicks the next button */
          btnNext.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  displayNextAlert(); // call method defined later in the program
              }
          });
  
          btnClear.setOnClickListener(new View.OnClickListener() {
              @Override
  
                  public void onClick(View v) {
                      ClearTextAlert(); // call method defined later in the program
                  }
          });
  
  
      }
  
  
      private void displayNextAlert() {
  
          // Get what the user entered
          EditText nameInput = (EditText) findViewById(R.id.EditTextName);
          DatePicker dobInput = (DatePicker) findViewById(R.id.DatePickerDOB);
          EditText emailInput = (EditText) findViewById(R.id.EditTextEmail);
  
          String strName = nameInput.getText().toString();
          String strDOB = dobInput.getDayOfMonth() + "/"
                  + (dobInput.getMonth() + 1) + "/" + dobInput.getYear();
          String strEmail = emailInput.getText().toString();
  
  
          // Create and display the Alert dialog
          new AlertDialog.Builder(this)
                  .setTitle("Details entered")
                  .setMessage(
                          " Details entered:\n " + strName + "\n " + strDOB
                                  + "\n " + strEmail).setNeutralButton("Back",
                  new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                          // do nothing - it will just close when clicked
                      }
                  }).show();
      }
  
  
      private void ClearTextAlert(){
          EditText textView;
          final EditText textView1 = (EditText) findViewById(R.id.EditTextName);
          final EditText textView2 = (EditText) findViewById(R.id.EditTextEmail);
          final DatePicker dp = (DatePicker) this.findViewById(R.id.DatePickerDOB);
          dp.init(1980, 5, 1, null); // set to 1st June 1980 - note months start at 0
  
          textView1.setText("");
          textView2.setText("");
          dp.init(1980, 5, 1, null);
          Toast t = Toast.makeText(getApplicationContext(),
                  "Text Cleared",
                  Toast.LENGTH_SHORT);
          t.show();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_data_input, menu);
          return true;
      }
  
      /* Process the user's selection from the menu */
      public boolean onOptionsItemSelected(MenuItem item) {
          // Find which menu item was selected
          switch (item.getItemId()) { // item.getitemId() returns id of selected option
              case R.id.itemNext: // Next item was selected
                  displayNextAlert(); // call the same method as for the Next Button
                  return true;
              case R.id.itemExit: // Exit item was selected
                  popupToast("You want to exit but why not just start using another application?");
                  return true;
  
              case R.id.itemClear: // Clear item was selected
                  ClearTextAlert();
                  return true;
              default:
                  return super.onOptionsItemSelected(item);
          }
      }
  
      /* Utility method created to display a popup "toast" alert */
      private void popupToast(String message) {
          Toast.makeText(this, message, Toast.LENGTH_LONG).show();
      }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/LinearLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/name_prompt"
          tools:context=".DataInput" /&gt;
  
      &lt;EditText
          android:id="@+id/EditTextName"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:inputType="textPersonName" &gt;
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/question" /&gt;
  
      &lt;CheckBox
          android:id="@+id/checkBox1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView1"
          android:layout_below="@+id/textView1"
          android:text="@string/check_one" /&gt;
  
      &lt;CheckBox
          android:id="@+id/checkBox2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/checkBox1"
          android:layout_below="@+id/checkBox1"
          android:text="@string/check_two" /&gt;
  
      &lt;CheckBox
          android:id="@+id/checkBox3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/checkBox2"
          android:text="@string/check_three" /&gt;
  
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/DOB_prompt" /&gt;
  
      &lt;DatePicker
          android:id="@+id/DatePickerDOB"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/email_prompt" /&gt;
  
      &lt;EditText
          android:id="@+id/EditTextEmail"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:inputType="textEmailAddress" /&gt;
  
      &lt;Button
          android:id="@+id/ButtonNext"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/next_command_prompt" /&gt;
  
      &lt;Button
          android:id="@+id/ButtonClear"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/clear_command_prompt" /&gt;
  
  &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;resources&gt;
  
      &lt;string name="app_name"&gt;FormInput&lt;/string&gt;
      &lt;string name="menu_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="title_activity_data_input"&gt;Enter your details&lt;/string&gt;
      &lt;string name="name_prompt"&gt;Name:&lt;/string&gt;
      &lt;string name="DOB_prompt"&gt;Date Of Birth:&lt;/string&gt;
      &lt;string name="email_prompt"&gt;Email:&lt;/string&gt;
      &lt;string name="next_command_prompt"&gt;Next&lt;/string&gt;
      &lt;string name="exit_command_label"&gt;Exit&lt;/string&gt;
      &lt;string name="clear_command_prompt"&gt;Clear&lt;/string&gt;
      &lt;string name="check_one"&gt;Sports&lt;/string&gt;
      &lt;string name="check_two"&gt;Reading&lt;/string&gt;
      &lt;string name="check_three"&gt;Sleeping&lt;/string&gt;
      &lt;string name="question"&gt;Hobbies:&lt;/string&gt;
  
  &lt;/resources&gt;</code></pre>
  </div>
  </div>
  </p>