TimePickerDialog 构造函数问题

TimePickerDialog Constructor Issues

if (v == btnEndTimePicker) {

            final Calendar c = Calendar.getInstance() ;
            mHour = c.get(Calendar.HOUR_OF_DAY);
            mMinutes = c.get(Calendar.MINUTE);
            TimePickerDialog timePickerDialog = new TimePickerDialog(true, this,
                    (view, hour, minutes) -> {
                        return editStartTime.setText((hour + ":" + minutes), mHour, mMinutes);
                    });
            timePickerDialog.show();
        }
        if (v == btnStartTimePicker) {

            final Calendar c = Calendar.getInstance() ;
            sHour = c.get(Calendar.HOUR_OF_DAY);
            sMinutes = c.get(Calendar.MINUTE);
            CalendarDialog timePickerDialog = new CalendarDialog(true, this,
                    (view, hour, minutes) -> {
                        return editStartTime.setText((hour + ":" + minutes), sHour, sMinutes);
                    });
            timePickerDialog.show();
        }

我不确定在这里做什么,我使用了类似的代码来弹出日历日期对话框并选择一个日期,然后将其放入 EditText 字段中。当我为 TimePickerDialog 做这件事时,它说它期待一个 char[] 而不是 String.

您为 TimePickerDialog 对象的获取提供了错误的参数

     public TimePickerDialog (Context context,  
            TimePickerDialog.OnTimeSetListener listener, 
            int hourOfDay, 
            int minute, 
            boolean is24HourView)

替换这个

  TimePickerDialog timePickerDialog = new TimePickerDialog(true, this,
                (view, hour, minutes) -> {
                    return editStartTime.setText((hour + ":" + minutes), mHour, mMinutes);
                });

TimePickerDialog timePickerDialog = new TimePickerDialog(this,listener,2,25,true);

这些是正确的参数以供查看

https://developer.android.com/reference/android/app/TimePickerDialog