java - DatePickerDialog crash -
i'm android newbie...
this code:
final button taskdatebutton = (button)findviewbyid(r.id.tasktimebutton); taskdatebutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { datepickerdialog datepickerdialog = new datepickerdialog(taskactivity.this, new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { taskdatecalendar.set(calendar.year, year); taskdatecalendar.set(calendar.month, monthofyear); taskdatecalendar.set(calendar.day_of_month, dayofmonth); taskdate = taskdatecalendar.gettime(); setdatebuttonswithdates(); timepickerdialog timepickerdialog = new timepickerdialog(taskactivity.this, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(timepicker view, int hourofday, int minute) { taskdatecalendar.set(calendar.hour_of_day, hourofday); taskdatecalendar.set(calendar.minute, minute); taskdate = taskdatecalendar.gettime(); setdatebuttonswithdates(); } }, taskdatecalendar.get(calendar.hour_of_day), taskdatecalendar.get(calendar.minute), false); timepickerdialog.show(); } }, taskdatecalendar.get(calendar.year), taskdatecalendar.get(calendar.month), taskdatecalendar.get(calendar.day_of_month)); datepickerdialog.show(); } });
it seems crashing when loading datepickerdialog, on line:
datepickerdialog datepickerdialog = new datepickerdialog(taskactivity.this, new datepickerdialog.ondatesetlistener() {
i looked around couldn't see what's causing this.
this error get:
java.lang.nullpointerexception: attempt invoke virtual method 'int java.util.calendar.get(int)' on null object reference
any help?
thanks
your taskdatecalendar
object seems null. call taskdatecalendar = calendar.getinstance()
before taskdatecalendar.set(calendar.year, year)
.
Comments
Post a Comment