title: Get date and time picker value from a single dialog fragment and set it in EditText
body: <p>I am working on an application in which the user can set the date and time. I want to set the date and time in a single dialog fragment and set it to edit text. Is it possible to use a date and time picker in 1 dialog fragment? If it is, how do you do it?
  Currently I am getting the time from the dialog fragment and then setting it to the <code>EditText</code>.</p>
  
  <p>My code is</p>
  
  <pre><code>LaterTextView=(TextView)findViewById(R.id.PickUp_later_TextView);
  
  
  
         LaterTextView.setOnClickListener(new View.OnClickListener() {
  
              @SuppressWarnings("deprecation")
              public void onClick(View v) {
                  showDialog(TIME_DIALOG_ID);
  
                  }
          });
  
  
  
  
  }
  
  
  protected Dialog onCreateDialog(int id) {
      switch (id) {
      case TIME_DIALOG_ID:
  
          // set time picker as current time
          return new TimePickerDialog(this, timePickerListener, hour, minute,
                  false);
  
      }
      return null;
  }
  
  private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
      public void onTimeSet(TimePicker view, int selectedHour,
              int selectedMinute) {
          hour = selectedHour;
          minute = selectedMinute;
  
          // set current time into TextView
          setDate_time_EditTExt.setText(new StringBuilder().append(pad(hour))
                  .append(":").append(pad(minute)));
  
  
  
      }
  };
  private static String pad(int c) {
      if (c &gt;= 10)
          return String.valueOf(c);
      else
          return "0" + String.valueOf(c);
  }
  </code></pre>
  
  <p>I want to set the date and time from the same dialog fragment.</p>