日期对话框onDateSet函数运行两次

时间:2014-08-08 16:21:13

标签: android dialog

public String date_dialog()
         {
             final Calendar c = Calendar.getInstance();
             mYear = c.get(Calendar.YEAR);
             mMonth = c.get(Calendar.MONTH);
             mDay = c.get(Calendar.DAY_OF_MONTH);

             DatePickerDialog dpd = new DatePickerDialog(this,
                     new DatePickerDialog.OnDateSetListener() {

                         @Override
                         public void onDateSet(DatePicker view, int year,
                                 int monthOfYear, int dayOfMonth) 
                         {
                             date=dayOfMonth + "-"+ (monthOfYear + 1) + "-" + year;
                            Toast.makeText(Mark_attendence.this,dayOfMonth + "-"+ (monthOfYear + 1) + "-" + year , Toast.LENGTH_LONG).show();


                         }
                     }, mYear, mMonth, mDay);
             dpd.show();

             return(date);
         }

ondateset函数中的这个toast运行了两次,当我单击对话框上的done按钮时,为什么会这样?

0 个答案:

没有答案