android - Date Picker Dialogue . App crashes when i set Max and Min date -
i have date picker dialogue in if set max date , min date ,the app crashes. whereas if set min date or max date works fine.. me find out i'm going wrong.
private void setdate(view c_c) { // todo auto-generated method stub final dialog dialog = new dialog(getparent()); dialog.setcontentview(r.layout.date_picker); dialog.settitle("select date"); datepicker calendarview = (datepicker) dialog.findviewbyid(r.id.date_picker_datepicker); try { log.d("***enc_date****",utility.getcurrentdate()+"*******"+utility.convertstringtomilli(utility.getcurrentdate())); calendarview.setmindate(utility.convertstringtomilli(utility.convertstringformat(commonobjects.patientsdtoencounter.getepisodedate()))); calendarview.setmaxdate(utility.convertstringtomilli(utility.getcurrentdate())); } catch (exception e) { e.printstacktrace(); } button button = (button) dialog.findviewbyid(r.id.btn_cancel_datepicker); button.setonclicklistener(new onclicklistener() { public void onclick(view v) { dialog.dismiss(); } }); button = (button) dialog.findviewbyid(r.id.btn_set_datepicker); button.settag(c_c); // if button clicked, close custom dialog button.setonclicklistener(new onclicklistener() { public void onclick(view v) { dialog.dismiss(); } }); dialog.show(); }
and log.
08-26 11:31:26.127: d/***enc_date****(1763): 26-aug-13*******1377455400000 08-26 11:31:26.427: d/androidruntime(1763): shutting down vm 08-26 11:31:26.427: w/dalvikvm(1763): threadid=1: thread exiting uncaught exception (group=0x40a13300) 08-26 11:31:26.589: e/androidruntime(1763): fatal exception: main 08-26 11:31:26.589: e/androidruntime(1763): java.lang.nullpointerexception 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.calendarview.onscroll(calendaview.java:1214) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.calendarview.access$900(calendarview.java:76) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.calendarview$2.onscroll(calendarview.java:1075) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.abslistview.invokeonitemscrolllistener(abslistview.java:1326) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.listview.layoutchildren(listview.java:1707) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.abslistview.onlayout(abslistview.java:2106) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.setchildframe(linearlayout.java:1649) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.layoutvertical(linearlayout.java:1507) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.onlayout(linearlayout.java:1420) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.framelayout.onlayout(framelayout.java:448) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ ndroid.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.setchildframe(linearlayout.java:1649) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.layouthorizontal(linearlayout.java:1638) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.onlayout(linearlayout.java:1422) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.framelayout.onlayout(framelayout.java:448) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.setchildframe(linearlayout.java:1649) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.layoutvertical(linearlayout.java:1507) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.onlayout(linearlayout.java:1420) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.framelayout.onlayout(framelayout.java:448) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.framelayout.onlayout(framelayout.java:448) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.setchildframe(linearlayout.java:1649) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.linearlayout.layoutvertical(linearlayout.java:1507) 08-26 11:31:26.589: e/androidruntime(1763): @ ndroid.widget.linearlayout.onlayout(linearlayout.java:1420) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.widget.framelayout.onlayout(framelayout.java:448) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.view.layout(view.java:13754) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewgroup.layout(viewgroup.java:4364) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewrootimpl.performlayout(viewrootimpl.java:1868) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1689) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1000) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4214) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.choreographer$callbackrecord.run(choreographer.java:725) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.choreographer.docallbacks(choreographer.java:555) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.choreographer.doframe(choreographer.java:525) 08-26 11:31:26.589: e/androidruntime(1763): @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) 08-26 11:31:26.589: e/androidruntime(1763): @ android.os.handler.handlecallback(handler.java:615) 08-26 11:31:26.589: e/androidruntime(1763): @ android.os.handler.dispatchmessage(handler.java:92) 08-26 11:31:26.589: e/androidruntime(1763): @ android.os.looper.loop(looper.java:137) 08-26 11:31:26.589: e/androidruntime(1763): @ android.app.activitythread.main(activitythread.java:4745) 08-26 11:31:26.589: e/androidruntime(1763): @ java.lang.reflect.method.invokenative(native method) 08-26 11:31:26.589: e/androidruntime(1763): @ java.lang.reflect.method.invoke(method.java:511) 08-26 11:31:26.589: e/androidruntime(1763): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 08-26 11:31:26.589: e/androidruntime(1763): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 08-26 11:31:26.589: e/androidruntime(1763): @ dalvik.system.nativestart.main(native method)
i had same problem you. in app have fragment extends datepickerdialog , displays on click of button. app chrashed on larger screens there enough space display calendar view of date picker. app, however, calendar view not wanted, , disabling it, app did not crash more when setting both min , max dates.
so, if it's case app don't need calendar view, try disabling calling setcalendarviewshown(false) on date picker instance.
Comments
Post a Comment