android - Listener for DatePickerDialog +/- button -


i'm using datepickerdialog in android app.

as everyone, knows dialog has 3 edittexts: 1) day 2) month 3) year. , there + , - buttons 3 move front , of selected field. need know if there exists listener "+" , "-" buttons in dialog?

this because, in app, don't want user select previous dates before current date using dialog. if "-" button clicked, should check whether date in dialog less current date. need listener "-" button of dialog.

also i'm developing app platforms starting froyo kitkat. have heard there setmindate() datepicker. available honeycomb.

try overriding ondatechnaged() function, here example:

datepickerdialog mdatepickerdialog = new datepickerdialog(this, mdatesetlistener,myear, mmonth, mday){                 @override                 public void ondatechanged(datepicker view, int year, int monthofyear, int dayofmonth){                     // function call when user click on '+' or '-'. apply validation here. can call view.updatedate(myear, mmonth, mday); if u don't want accept date user trying select pressing +/-                      final calendar c = calendar.getinstance();                     myear = c.get(calendar.year);                     mmonth = c.get(calendar.month);                     mday = c.get(calendar.day_of_month);                     /* validation allow user enter date less current date */                     if (year > myear)                         view.updatedate(myear, mmonth, mday);

                if (monthofyear > mmonth && year == myear)                     view.updatedate(myear, mmonth, mday);                  if (dayofmonth > mday && year == myear && monthofyear == mmonth)                     view.updatedate(myear, mmonth, mday);             }         }; 

datepickerdialog.ondatesetlistener mdatesetlistener = new datepickerdialog.ondatesetlistener() { public void ondateset(datepicker view, int year, int monthofyear,int dayofmonth) { // add code here handle selected date event user

} };

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -