title: How to show Selected Date in EditText using DialogFragment
body: <p>I am using <code>DialogFragment</code> to show <code>DatePicker</code> when user taps on <code>EditText</code></p>
  
  <p>How can i show the selected date in the same <code>EditText</code>.</p>
  
  <p>I am using <a href="http://developer.android.com/guide/topics/ui/controls/pickers.html" rel="nofollow">this</a> as a reference.</p>
  
  <p><strong>DatePickerFragment.java:</strong></p>
  
  <pre><code>public class DatePickerFragment extends DialogFragment
          implements DatePickerDialog.OnDateSetListener {
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // Use the current date as the default date in the picker
          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);
  
          // Create a new instance of DatePickerDialog and return it
          return new DatePickerDialog(getActivity(), this, year, month, day);
      }
  
      @Override
      public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
          Calendar c = Calendar.getInstance();
          c.set(year, monthOfYear, dayOfMonth);
  
          SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
          String formattedDate = sdf.format(c.getTime());
          Toast.makeText(getActivity(), formattedDate, Toast.LENGTH_LONG).show();
      }
  
  }
  </code></pre>
  
  <p><strong>Fragment:</strong></p>
  
  <pre><code>editDate.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  android.support.v4.app.DialogFragment dialogFragment = new DatePickerFragment();
                  dialogFragment.show(getFragmentManager(), "datePicker");
              }
          });
  </code></pre>
  
  <p>When I tap on EditText, it shows <code>DatePicker</code> and selected date in a <strong><code>Toast</code></strong>. But I can't figure out how to show that date in the <code>EditText</code> ?</p>