Android: DatePicker and DatePicker Dialog

前端 未结 8 585
梦如初夏
梦如初夏 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:06

    You can try this code.. it will surely helpful to u.. No Doubt!

        protected Dialog onCreateDialog(int id) {
    
        Calendar c=Calendar.getInstance();
        int Sysday=c.get(Calendar.DAY_OF_MONTH);
        int Sysmonth=c.get(Calendar.MONTH);
        int Sysyear=c.get(Calendar.YEAR);
    
        int Sysmin=c.get(Calendar.MINUTE);
        int Syshour=c.get(Calendar.HOUR);
    
    
        switch (id) {
        case TIME_DIALOG:
    
            return new TimePickerDialog(this, myTimePicker , Syshour, Sysmin, false);
    
        case DATE_DIALOG:
            return new DatePickerDialog(this, myDatePicker, Sysyear, Sysmonth, Sysday);
        }
        return null;
    }
    

提交回复
热议问题