开发者

Duplicate case error during implementation of two dialogs

I am trying to implement both the date picker and time picker. However, when I try to define two cases in the following code, I get an error that there is a duplicate case.

Code:

@Override
protected Dialog onCreateDialog(int id) 
{
    switch(id){
    case ID_DATEPICKER:
        Toast.makeText(SendMail.this, "Select Appointment Date", 
                                                 Toast.LENGTH_LONG).show();
        return new DatePickerDialog(this, myDateSetListener, myYear, my开发者_运维技巧Month, myDay);
    case TIME_DIALOG_ID:
        Toast.makeText(SendMail.this, "Select Appointment Time", Toast.LENGTH_LONG).show();
        return new TimePickerDialog(this,mTimeSetListener, 0, 0, false);
    default:
        return null;
    }
}

What is the solution?


make sure ID_DATEPICKER and TIME_DIALOG_ID do not have the same int value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜