Perfect Picker Date Android

DatePickerDialog mDatePickerDialog = null;
               final Calendar mCalendar = Calendar.getInstance();
               if (mDatePickerDialog == null) {
                   mDatePickerDialog = new DatePickerDialog(getActivity(),
                           new DatePickerDialog.OnDateSetListener() {
                               @Override
                               public void onDateSet(DatePicker view, int year,
                                                     int monthOfYear, int dayOfMonth) {
                                   // TODO Auto-generated method stub
                                     /*  edit_gi_age.setText(String.format(
                                               "%04d-%02d-%02d", year, monthOfYear + 1,
                                               dayOfMonth));*/
                                   edit_gi_age.setText(String.valueOf(getAge1(year, monthOfYear, dayOfMonth)));
                                   txt_ov_age.setText(String.valueOf(getAge1(year, monthOfYear, dayOfMonth)));
                                   mCalendar.set(Calendar.YEAR, year);
                                   mCalendar.set(Calendar.MONTH, monthOfYear);
                                   mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                               }
                           }, 1970, 0, 1);
                   mCalendar.set(Calendar.YEAR, 1970);
                   mCalendar.set(Calendar.MONTH, 0);
                   mCalendar.set(Calendar.DAY_OF_MONTH, 1);
                   mDatePickerDialog.setCanceledOnTouchOutside(true);
                   mDatePickerDialog
                           .setTitle(getString(R.string.app_name));
                   mDatePickerDialog.getDatePicker().setMaxDate(calendar.getTimeInMillis());
                   mDatePickerDialog.getDatePicker().setMinDate(mCalendar.getTimeInMillis());
               }
               mDatePickerDialog.show();

No comments:

Post a Comment