I have a datepicker which disables past dates.
For my application, for example, certain events might happen only on every 'Fridays and Mondays' of every week. In that case the user must be able to select only Fridays and Mondays. The other dates must be disabled for selection. I do not want to validate after selection.
Please let me know if this is possible.
date picker code :
final Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
dpd = new DatePickerDialog(InfoActivity.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int month, int dayOfMonth) {
month+=1;
String day = ""+dayOfMonth;
String mon = ""+ month;
try {
date=convertToINDateFormat(mon+"/"+day+"/"+year);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, mYear, mMonth, mDay);
dpd.setButton( DatePickerDialog.BUTTON_POSITIVE, "Set", new DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dialog, int which )
{
Intent i = new Intent(InfoActivity.this, ChooseSlot.class);
startActivity(i);
finish();
}
} );
. . . . . . .
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
Date newDate = c.getTime();
dpd.getDatePicker().setMinDate(newDate.getTime());
dpd.show();