title: Default DatePicker Dialog Change Both DatePicker Dates According to Selection
body: <p>I have two date picker dialogs, I want to change the date and set maximum and minimum according to the selection of both dialog pickers.
      If I select a "start date", end date should start with "start date" selected values, and if I select "end date" first "start date" maximum date should "end date" selected  value.</p>
  
  <pre><code>private DatePickerDialog datePickerOne;
  private DatePickerDialog datePickeTwo;
  
  private void MyListener() { 
  final Calendar calendarMain = Calendar.getInstance();
  Year = calendarMain.get(Calendar.YEAR);
  Month = calendarMain.get(Calendar.MONTH);
  Day = calendarMain.get(Calendar.DAY_OF_MONTH);
  
  
  datePickerOne = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() {
  
      @Override 
      public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
  
          Year = year;
          Month = monthOfYear;
          Day = dayOfMonth;
  
          StringBuilder selectedDateFrom = new StringBuilder().append(dayOfMonth).append("-").append(monthOfYear + 1).append("-").append(year);
          textDateStart.setText(selectedDateFrom);
          textDateStart.setTextColor(android.graphics.Color.BLACK);
  
          Calendar c2 = Calendar.getInstance();
              int yearResp=c2.get(Calendar.YEAR);
          int monthResp=c2.get(Calendar.MONTH);
          int dayResp=c2.get(Calendar.DAY_OF_MONTH);
  
          datePickerTwo.getDatePicker().setMinDate(c2.getTime().getTime());
           datePickerTwo.updateDate(dayResp, monthResp,yearResp);
          datePickerTwo.getDatePicker().setMaxDate(new Date().getTime()); 
  
  
      } 
  }, Year, Month, Day); 
  
  textDateStart.setOnClickListener(new View.OnClickListener() {
      @Override 
      public void onClick(View view) {
  
          datePickerOne.show(); 
  
  
      } 
  
  
  }); 
  
  datePickerTwo = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() {
      @Override 
      public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
  
          Year = year;
          Month = monthOfYear;
          Day = dayOfMonth;
  
          StringBuilder selectedDateTO = new StringBuilder().append(dayOfMonth).append("-").append(monthOfYear + 1).append("-").append(year);
          textDateEnd.setText(selectedDateTO);
  
          textDateEnd.setTextColor(android.graphics.Color.BLACK);
  
          Calendar c3 = Calendar.getInstance();
            int yearResp=c3.get(Calendar.YEAR);
          int monthResp=c3.get(Calendar.MONTH);
          int dayResp=c3.get(Calendar.DAY_OF_MONTH);
          datePickerOne.getDatePicker().setMaxDate(c3.getTime().getTime());
         datePickerOne.updateDate(dayResp, monthResp,yearResp);
          datePickerOne.getDatePicker().setMinDate(new Date().getTime()); 
  
      } 
  }, Year, Month, Day); 
  
  textDateEnd.setOnClickListener(new View.OnClickListener() {
      @Override 
      public void onClick(View view) {
  
  
  
          datePickerTwo.show(); 
  
  
      } 
  
  }); 
  </code></pre>
  
  <p>Now initial time only I can change values, next time is not working. Here datepicker dialogs are datePickerOne and datePickerTwo. textDateStart and textDateEnd are textviews.</p>