I have tried to much but nothing works for me can anybody help me how to disable certain dates in calender here is my code but its just hiding past dates.
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(MoreDetail.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
String s = dayOfMonth + "" + "-" + monthOfYear + 1 + "" + "-" + year + "";
}
}, mYear, mMonth, mDay);
Calendar minDate = Calendar.getInstance();
minDate.set(mYear, mMonth, mDay);
datePickerDialog.getDatePicker().setMinDate(minDate.getTimeInMillis());
datePickerDialog.show();
Please check this GitHub repo for CustomDatePicker
.
https://github.com/wdullaer/MaterialDateTimePicker
setDisabledDays(Calendar[] days)
The values in this Calendar[] are explicitly disabled (not selectable). This option can be used together with setSelectableDays(Calendar[] days): in case there is a clash setDisabledDays(Calendar[] days) will take precedence over setSelectableDays(Calendar[] days)
Thanks.