How set maximum date in datepicker dialog in android? -
in application using date picker set date.i want set date picker maximum date today date according system date.i don't know how set date picker maximum date today date.can 1 know me solve problem.
my date picker coding is:
private int pyear; private int pmonth; private int pday; static final int date_dialog_id = 0; final calendar c = calendar.getinstance(); pyear = c.get(calendar.year); pmonth = c.get(calendar.month); pday = c.get(calendar.day_of_month); // date picker public dialog oncreatedialog(int id) { switch (id) { case date_dialog_id: datepickerdialog.ondatesetlistener pdatesetlistener = new datepickerdialog.ondatesetlistener() { public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { pyear = year; pmonth = monthofyear; pday = dayofmonth; e_dob.settext(new stringbuilder() // set date in editext .append(pday).append("/").append(pmonth + 1) .append("/").append(pyear).append(" ")); } }; return new datepickerdialog(this, pdatesetlistener, pyear, pmonth, pday); } return null; }
use setmaxdate()
.
for example, replace return new datepickerdialog(this, pdatesetlistener, pyear, pmonth, pday)
statement this:
datepickerdialog dialog = new datepickerdialog(this, pdatesetlistener, pyear, pmonth, pday); dialog.getdatepicker().setmaxdate(new date().gettime()); return dialog;
Comments
Post a Comment