非法参数异常的机器人对话机器人、异常、参数

2023-09-07 04:54:41 作者:暧啶吥离

我用这code以示警告对话框......当我点击确定按钮,它应该显示的日期选择器。

 保护对话框onCreateDialog(INT ID){
    开关(ID){
    案例TIME_DIALOG_ID:
        返回新TimePickerDialog(ListReminderActivity.this,
                mTimeSetListener,mHour,mMinute,假);
    案例DATE_DIALOG_ID:
        返回新DatePickerDialog(ListReminderActivity.this,
                mDateSetListener,mYear,mMonth,MDAY);
    案例DESCRIPTION_DIALOG_ID:
        返回新AlertDialog.Builder(ListReminderActivity.this).setTitle(
                添加提醒)。的setView(介绍).setPositiveButton(
                R.string.add_alert_ok,
                新DialogInterface.OnClickListener(){
                    公共无效的onClick(DialogInterface对话框,
                            INT whichButton){
                        ListReminderActivity.this
                                .dismissDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .removeDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .showDialog(DATE_DIALOG_ID);
                    }
                })。setNegativeButton(R.string.add_alert_cancel,
                新DialogInterface.OnClickListener(){
                    公共无效的onClick(DialogInterface对话框,
                            INT whichButton){
                        ListReminderActivity.this
                                .dismissDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .removeDialog(DESCRIPTION_DIALOG_ID);
                    }
                })。创建();
    }
    返回null;
}
 

但问题是..我得到异常时,我clcik确定按钮

例外是...

 十月九日至九号:30:48.941:ERROR / AndroidRuntime(1189):致命异常:主要
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189):java.lang.IllegalArgumentException:如果电流应与GT; =启动和< =结束
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.widget.DatePicker.updateDaySpinner(DatePicker.java:364)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.widget.DatePicker.updateSpinners(DatePicker.java:350)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.widget.DatePicker.init(DatePicker.java:346)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.DatePickerDialog< INIT>(DatePickerDialog.java:124)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.DatePickerDialog< INIT>(DatePickerDialog.java:83)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在com.app.reminder.ListReminderActivity.onCreateDialog(ListReminderActivity.java:149)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.Activity.onCreateDialog(Activity.java:2472)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.Activity.createDialog(Activity.java:881)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.Activity.showDialog(Activity.java:2547)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.Activity.showDialog(Activity.java:2514)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在com.app.reminder.ListReminderActivity $ 3.onClick(ListReminderActivity.java:164)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在com.android.internal.app.AlertController $ ButtonHandler.handleMessage(AlertController.java:158)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.os.Handler.dispatchMessage(Handler.java:99)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.os.Looper.loop(Looper.java:123)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在android.app.ActivityThread.main(ActivityThread.java:4627)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在java.lang.reflect.Method.invokeNative(本机方法)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在java.lang.reflect.Method.invoke(Method.java:521)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10月9号至9号:30:48.941:ERROR / AndroidRuntime(1189年):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

如由你的日志中看到错误,你mYear,mMonth或MDAY价值之一是无效的。

干货 阿里云小蜜对话机器人背后的核心算法

i am using this code to show alert dialog...when i click on the ok button it should show the date picker..

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case TIME_DIALOG_ID:
        return new TimePickerDialog(ListReminderActivity.this,
                mTimeSetListener, mHour, mMinute, false);
    case DATE_DIALOG_ID:
        return new DatePickerDialog(ListReminderActivity.this,
                mDateSetListener, mYear, mMonth, mDay);
    case DESCRIPTION_DIALOG_ID:
        return new AlertDialog.Builder(ListReminderActivity.this).setTitle(
                "Add Reminder").setView(description).setPositiveButton(
                R.string.add_alert_ok,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,
                            int whichButton) {
                        ListReminderActivity.this
                                .dismissDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .removeDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .showDialog(DATE_DIALOG_ID);
                    }
                }).setNegativeButton(R.string.add_alert_cancel,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,
                            int whichButton) {
                        ListReminderActivity.this
                                .dismissDialog(DESCRIPTION_DIALOG_ID);
                        ListReminderActivity.this
                                .removeDialog(DESCRIPTION_DIALOG_ID);
                    }
                }).create();
    }
    return null;
}

but the problem is.. i am getting the Exception when i clcik on the ok button

Exception is...

    09-09 10:30:48.941: ERROR/AndroidRuntime(1189): FATAL EXCEPTION: main
09-09 10:30:48.941: ERROR/AndroidRuntime(1189): java.lang.IllegalArgumentException: current should be >= start and <= end
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.widget.DatePicker.updateDaySpinner(DatePicker.java:364)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.widget.DatePicker.updateSpinners(DatePicker.java:350)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.widget.DatePicker.init(DatePicker.java:346)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.DatePickerDialog.<init>(DatePickerDialog.java:124)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.DatePickerDialog.<init>(DatePickerDialog.java:83)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at com.app.reminder.ListReminderActivity.onCreateDialog(ListReminderActivity.java:149)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.Activity.onCreateDialog(Activity.java:2472)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.Activity.createDialog(Activity.java:881)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.Activity.showDialog(Activity.java:2547)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.Activity.showDialog(Activity.java:2514)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at com.app.reminder.ListReminderActivity$3.onClick(ListReminderActivity.java:164)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.os.Looper.loop(Looper.java:123)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at java.lang.reflect.Method.invokeNative(Native Method)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at java.lang.reflect.Method.invoke(Method.java:521)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-09 10:30:48.941: ERROR/AndroidRuntime(1189):     at dalvik.system.NativeStart.main(Native Method)

解决方案

As indicated by the error you see in the logs, one of your mYear, mMonth or mDay values is invalid.