Android无法在TimePickerDialog上解析构造函数

时间:2015-02-25 03:47:53

标签: android android-timepicker

请帮我处理我的代码。我收到这样的错误

error: no suitable constructor found for TimePickerDialog(MyHttpPostProjectActivity,<anonymous OnTimeSetListener>,int,int)
constructor TimePickerDialog.TimePickerDialog(Context,int,OnTimeSetListener,int,int,boolean) is not applicable
(actual and formal argument lists differ in length)
constructor TimePickerDialog.TimePickerDialog(Context,OnTimeSetListener,int,int,boolean) is not applicable
(actual and formal argument lists differ in length)

startTimePicker = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
            startTimeField.setText(selectedHour + ":" + selectedMinute);
        }
    }, hour, minute);        
    startTimePicker.show();

1 个答案:

答案 0 :(得分:0)

再输入一个参数为false

startTimePicker = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
    @Override
    public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
        startTimeField.setText(selectedHour + ":" + selectedMinute);
    }
}, hour, minute, false);        
startTimePicker.show();