Android calling system comes with calendar pop-up box

Calendar popup

Hello everyone, I was studying how to write my own calendar pop-up box before, but later I found that the system’s own calendar pop-up box function has already been launched, but as I said, look at the following code:

   //日历
    private void showDatePickDlg() {
    
    
        Calendar calendar=Calendar.getInstance();
        DatePickerDialog dialog=new DatePickerDialog(AllSearchActivity.this, new DatePickerDialog.OnDateSetListener() {
    
    
            @Override
            public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
    
    
                Log.d("info","返回的日期是=="+year+ "年" + monthOfYear + "月" + dayOfMonth+"日");
            }
        }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }

OK It's that simple. I was surprised at the time. Hahaha, it saves me a lot of trouble.

Guess you like

Origin blog.csdn.net/mawlAndroid/article/details/120202728