Android: DatePicker and DatePicker Dialog

前端 未结 8 567
梦如初夏
梦如初夏 2020-12-24 09:23

I have this code here on the options menu

Dialog dialog = new Dialog(ScheduleActivity.this);
dialog.setTitle(\"Add Event\");
dialog.setContentView(R.layout.         


        
8条回答
  •  青春惊慌失措
    2020-12-24 10:09

    Calendar c1 = Calendar.getInstance();    
    int year = c1.get(Calendar.YEAR);
    int month = c1.get(Calendar.MONTH);
    int day = c1.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog.OnDateSetListener myDateListener  = new DatePickerDialog.OnDateSetListener() {
    
           public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
                       if(arg0.isShown()){
    
                                         //do further code here
    
                                  }
                                }
    
                              };
            DatePickerDialog dp = new DatePickerDialog(YourActivity.this, myDateListener, year, month, day);
            dp.show();      
    

提交回复
热议问题