android – java.lang.IllegalArgumentException:current应该> = start并且<= end

android – java.lang.IllegalArgumentException:current应该> = start并且<= end,第1张

概述我正在尝试在 android中的按钮上实现日期选择器.但是一旦我点击按钮错误d出.但时间选择器运行良好.这是代码: mPickDate.setOnClickListener(new View.OnClickListener() { //Assigning onClickListener to Date Button 我正在尝试在 android中的按钮上实现日期选择器.但是一旦我点击按钮错误d出.但时间选择器运行良好.这是代码:
mPickDate.setonClickListener(new VIEw.OnClickListener() {       //Assigning onClickListener to Date button                                                                          public voID onClick(VIEw v) {            showDialog(DATE_DIALOG_ID);            }        });    pickTime.setonClickListener(new VIEw.OnClickListener() {        //Assigning onClickListener to Time button        @OverrIDe        public voID onClick(VIEw v) {            showDialog(TIME_DIALOG_ID);        }    });    }    @OverrIDe    protected Dialog onCreateDialog(int ID) {                       //OverrIDing onCreateDialog()        switch (ID) {        case DATE_DIALOG_ID:            return new DatePickerDialog(this,mDateSetListener,mYear,mMonth,mDay);        case TIME_DIALOG_ID:            return new TimePickerDialog(this,mTimeSetListener,mHour,mMin,true);        }        return null;    }    TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {        //Defining the TimePickerDialog reference variable        @OverrIDe        public voID onTimeSet(TimePicker vIEw,int hourOfDay,int minute) {            mHour=hourOfDay;            mMin= minute;            updateTime();        }    };    DatePickerDialog.OnDateSetListener mDateSetListener =                       //Defining the DatePickerDialog reference variable        new DatePickerDialog.OnDateSetListener() {            public voID onDateSet(DatePicker vIEw,int year,int monthOfYear,int dayOfMonth) {                mYear = year;                mMonth = monthOfYear;                mDay = dayOfMonth;                updatedisplay();            }        };

这是logcat:

10-13 16:41:46.878: ERROR/AndroIDRuntime(761): FATAL EXCEPTION: main10-13 16:41:46.878: ERROR/AndroIDRuntime(761): java.lang.IllegalArgumentException: current should be >= start and <= end10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.Widget.NumberPicker.setCurrent(NumberPicker.java:288)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.Widget.DatePicker.updateDaySpinner(DatePicker.java:370)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.Widget.DatePicker.updateSpinners(DatePicker.java:356)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.Widget.DatePicker.init(DatePicker.java:352)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.DatePickerDialog.<init>(DatePickerDialog.java:127)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.DatePickerDialog.<init>(DatePickerDialog.java:86)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at acb.xiynove.Offlinescreen_ACBActivity.onCreateDialog(Offlinescreen_ACBActivity.java:74)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.Activity.onCreateDialog(Activity.java:2482)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.Activity.createDialog(Activity.java:882)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.Activity.showDialog(Activity.java:2557)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.Activity.showDialog(Activity.java:2524)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at acb.xiynove.Offlinescreen_ACBActivity.onClick(Offlinescreen_ACBActivity.java:56)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.vIEw.VIEw.performClick(VIEw.java:2485)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.vIEw.VIEw$PerformClick.run(VIEw.java:9080)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.os.Handler.handleCallback(Handler.java:587)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.os.Handler.dispatchMessage(Handler.java:92)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.os.Looper.loop(Looper.java:123)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at androID.app.ActivityThread.main(ActivityThread.java:3683)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at java.lang.reflect.Method.invokeNative(Native Method)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at java.lang.reflect.Method.invoke(Method.java:507)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:597)10-13 16:41:46.878: ERROR/AndroIDRuntime(761):     at dalvik.system.NativeStart.main(Native Method)
解决方法 我有同样的问题,但我找到了解决方案.你应该初始化mYear,mDay:
//Init this variables as you wish eg.:private int mYear = 2010;private int mMonth = 11;private int mDay =1;@OverrIDeprotected Dialog onCreateDialog(int ID) {                       //OverrIDing onCreateDialog()    switch (ID) {    case DATE_DIALOG_ID:        return new DatePickerDialog(this,mDay);    case TIME_DIALOG_ID:        return new TimePickerDialog(this,true);    }    return null;}
总结

以上是内存溢出为你收集整理的android – java.lang.IllegalArgumentException:current应该> = start并且<= end全部内容,希望文章能够帮你解决android – java.lang.IllegalArgumentException:current应该> = start并且<= end所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1134515.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存