title: View.OnClickListener in a custom DialogFragment
body: <p>I am trying to implement a custom <code>DialogFragment</code>, following <a href="http://developer.android.com/guide/topics/ui/dialogs.html#FullscreenDialog" rel="nofollow">this</a> tutorial. My problem is that I fail to handle my custom's view's button.setOnClickListener event. The strangest part is that I have no problem in geting the <code>.getText()</code> of my button, I just can't find a way to handle the click event. Bellow is my code:</p>
  
  <p>SettingsDialogFragment.java  </p>
  
  <pre><code> public class SettingsDialogFragment extends DialogFragment
  {
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState)
  {
  
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      // Get the layout inflater
      LayoutInflater inflater = getActivity().getLayoutInflater();
      final View view = inflater.inflate(R.layout.dialog_settings, null);
  
      final Button colorButton =(Button) view.findViewById(R.id.colorButton_dialogSettings);
      String s = colorButton.getText().toString();
      System.out.println("its working "+s);
  
      //NOT working
      colorButton.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              System.out.println("OnClick");
          }
      });
  
      // Inflate and set the layout for the dialog
      // Pass null as the parent view because its going in the dialog layout
      builder.setView(inflater.inflate(R.layout.dialog_settings, null))
              // Add action buttons
              .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int id)
                  {
  
                  }
              })
              .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      SettingsDialogFragment.this.getDialog().cancel();
                  }
              });
      return builder.create();
  }
  </code></pre>
  
  <p>`
  My custom view code (dialog_settings.xml)</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="200dp"
            android:layout_height="wrap_content"&gt;
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:gravity="center"
      android:scaleType="center"
      android:background="#00CCCC"
      android:contentDescription="@string/app_name"
      android:text="@string/dialog_settings_title"
      android:id="@+id/editText"/&gt;
  &lt;Button
      android:id="@+id/colorButton_dialogSettings"
      android:inputType="textEmailAddress"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="@string/color_picker_title"
      android:layout_below="@+id/editText"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      /&gt;
  
  &lt;RadioButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Stroke"
      android:layout_marginLeft="55dp"
      android:id="@+id/radioButtonStroke"
      android:checked="false"
      android:layout_below="@+id/colorButton_dialogSettings"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"/&gt;
  
  &lt;RadioButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Fill"
      android:id="@+id/radioButton_fill"
      android:checked="false"
      android:layout_below="@+id/colorButton_dialogSettings"
      android:layout_toRightOf="@+id/radioButtonStroke"
      android:layout_toEndOf="@+id/radioButtonStroke"
      android:layout_marginLeft="10dp"
      /&gt;
  </code></pre>
  
  <p></p>