android - setting minimum Date in DatePicker -
hello guys new android , facing problem have searched lot not getting solution m using datepickerdialog box , when running application selecting previous dates though have set minimum date. have tried subtracting 1 second current time. , datepicker starting january1990. want start today , block previous dates. ...
public void onbuttonclickdate() { btn_date = (button)findviewbyid(r.id.button); edit_date = (edittext)findviewbyid(r.id.edittext); btn_date.setonclicklistener ( new view.onclicklistener() { @override public void onclick(view view) { datepickerdialog datepickerdialog = new datepickerdialog(mainactivity.this, new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) view.setmindate(system.currenttimemillis()); edit_date.settext(dayofmonth + "-" + (monthofyear + 1) + "-" + year); } }, myear, mmonth, mday); datepickerdialog.show(); } } ); }
try adjusting code this.
btn_date = (button) findviewbyid(r.id.button); edit_date = (edittext) findviewbyid(r.id.edittext); datepickerdialog datepickerdialog = new datepickerdialog(mainactivity.this, new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { datepickerdialog.setmindate(system.currenttimemillis()); myear = year; mmonth = monthofyear; mday = dayofmonth; edit_date.settext(dayofmonth + "-" + (monthofyear + 1) + "-" + year); } }, myear, mmonth, mday); datepickerdialog.setmindate(system.currenttimemillis()); btn_date.setonclicklistener( new view.onclicklistener() { @override public void onclick(view view) { datepickerdialog.show(); } } );
android calendar view cascade of bugs. if above method fails can try removing calendarview picker. other methods bypass these bugs are described here
datepicker.setcalendarviewshown(false);
alternatively try using a library functionality
compile "com.wdullaer:materialdatetimepicker:2.4.0"
Comments
Post a Comment