title: Retrieve and set data from DialogFragment (DatePicker)
body: <p>My DialogFragment class is invoked when I press a button on a activity. I want the date set through this DialogFragment to be displayed on the buttons text. 
  FindViewById refuses to be recognized by the class. </p>
  
  <p>I found a <a href="https://stackoverflow.com/questions/6495898/findviewbyid-in-fragment-android">similar question</a> but I'm unable to relate it to my case.</p>
  
  <p>Code:</p>
  
  <ol>
  <li><p>Button which calls the Dialogue fragment:</p>
  
  <pre><code>public void datepicker(View v) {
      DialogFragment newFragment = new DatePickerFragment();
      newFragment.show(getFragmentManager(), "datePicker"); 
  }
  </code></pre></li>
  <li><p>Code for dialogue fragment:</p>
  
  <pre><code>public class DatePickerFragment extends DialogFragment implements
      DatePickerDialog.OnDateSetListener {
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceSateate) {
  
          final Calendar c = Calendar.getInstance();
              int year = c.get(Calendar.YEAR);
              int month = c.get(Calendar.MONTH);
              int day = c.get(Calendar.DAY_OF_MONTH);
  
              return new DatePickerDialog(getActivity(), this, year, month, day);
          }
  
          public void onDateSet(DatePicker view, int year, int month, int day) {
              // Do something with the date chosen
          }
      }
  }
  </code></pre></li>
  </ol>