0

i have to setMinDate with today in one DatePicker, and in second DatePicker i have to setMinDate with the previous date selected. I tried to search on internet but all the things that i tried didn't work. Can someone help me to solve this problem??

Thanks to every helps.

@Override
public void onClick(View view) {
    if(view == dataInizioCoupon) {
        fromDatePickerDialog.show();
    } else if(view == dataFineCoupon) {
        toDatePickerDialog.show();
    }

}

private void findViewsById() {

    dataInizioCoupon = (EditText) findViewById(R.id.textNuovoCouponDataInizio);
    dataInizioCoupon.setInputType(InputType.TYPE_NULL);
    dataInizioCoupon.requestFocus();

    dataFineCoupon = (EditText) findViewById(R.id.textNuovoCouponDataFine);
    dataFineCoupon.setInputType(InputType.TYPE_NULL);
}

private void setDateTimeField() {
    dataInizioCoupon.setOnClickListener(this);
    dataFineCoupon.setOnClickListener(this);

    Calendar newCalendar = Calendar.getInstance();

    fromDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            dataInizioCoupon.setText(dateFormatter.format(newDate.getTime()));
        }

    },newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));

    toDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);

            dataFineCoupon.setText(dateFormatter.format(newDate.getTime()));
        }

    },newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));

}
Flavio
  • 1

1 Answers1

0

I solved to setMinDate with today, but i still remain with problem to set minDate of second date picker with selected date of first date picker.

Flavio
  • 1