java - How to set year limit in DatePickerDialog in Android? -
i have been researching on putting limits in datepickerdialog
, nothing seems work, don't know wrong , how make work here current code:
public void getdate() { final calendar mycalendar = calendar.getinstance(); final datepickerdialog.ondatesetlistener date = new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // todo auto-generated method stub mycalendar.set(calendar.year, year); mycalendar.set(calendar.month, monthofyear); mycalendar.set(calendar.day_of_month, dayofmonth); updatelabel(); } }; birthdate.setontouchlistener(new view.ontouchlistener() { @suppresslint("clickableviewaccessibility") @override public boolean ontouch(view v, motionevent event) { if (event.getaction() == motionevent.action_down) { new datepickerdialog(register.this, date, mycalendar .get(calendar.year), mycalendar .get(calendar.month), mycalendar .get(calendar.day_of_month)).show(); } return true; } }); } private void updatelabel() { string myformat = "mm/dd/yy"; // in need put here simpledateformat sdf = new simpledateformat(myformat, locale.us); final calendar mycalendar = calendar.getinstance(); birthdate.settext(sdf.format(mycalendar.gettime())); } }
Comments
Post a Comment