我有一个日期选择器对话框,如果我将 MAX date 和 Min date 一起设置,则应用程序崩溃。而如果我只设置最小日期或最大日期它工作正常.. 帮助我找出我哪里出错了。
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 is clicked, close the custom dialog
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
这是我的日志。
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 with 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): at android.widget.CalendarView.onScroll(CalendaView.java:1214)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.CalendarView.access$900(CalendarView.java:76)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.CalendarView$2.onScroll(CalendarView.java:1075)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1326)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.ListView.layoutChildren(ListView.java:1707)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.AbsListView.onLayout(AbsListView.java:2106)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at a ndroid.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1638)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.onLayout(LinearLayout.java:1422)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
08-26 11:31:26.589: E/AndroidRuntime(1763): at a ndroid.widget.LinearLayout.onLayout(LinearLayout.java:1420)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.View.layout(View.java:13754)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewGroup.layout(ViewGroup.java:4364)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1868)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1689)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.Choreographer.doFrame(Choreographer.java:525)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.os.Handler.handleCallback(Handler.java:615)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.os.Handler.dispatchMessage(Handler.java:92)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.os.Looper.loop(Looper.java:137)
08-26 11:31:26.589: E/AndroidRuntime(1763): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-26 11:31:26.589: E/AndroidRuntime(1763): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 11:31:26.589: E/AndroidRuntime(1763): at java.lang.reflect.Method.invoke(Method.java:511)
08-26 11:31:26.589: E/AndroidRuntime(1763): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-26 11:31:26.589: E/AndroidRuntime(1763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-26 11:31:26.589: E/AndroidRuntime(1763): at dalvik.system.NativeStart.main(Native Method)