Example usage for android.app DatePickerDialog dismiss

List of usage examples for android.app DatePickerDialog dismiss

Introduction

In this page you can find the example usage for android.app DatePickerDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:at.jclehner.rxdroid.DatePickerFragment.java

@Override
public void onShow(DialogInterface dialogInterface) {
    if (Version.SDK_IS_JELLYBEAN_OR_NEWER) {
        final DatePickerDialog dialog = (DatePickerDialog) dialogInterface;
        dialog.getButton(Dialog.BUTTON_POSITIVE).setOnClickListener(new OnClickListener() {

            @TargetApi(11)/*from ww  w. ja v a  2 s .co m*/
            @Override
            public void onClick(View v) {
                final DatePicker picker = dialog.getDatePicker();
                mListener.onDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
                dialog.dismiss();
            }
        });
    }
}

From source file:uk.ac.horizon.artcodes.fragment.AvailabilityEditDialogFragment.java

private void selectDate(Long timestamp, final DateListener listener) {
    final Calendar calendar = Calendar.getInstance();
    if (timestamp != null) {
        calendar.setTimeInMillis(timestamp);
    } else {//from   w  ww  .  j  a  v a2s.com
        calendar.setTimeInMillis(System.currentTimeMillis());
    }
    int mYear = calendar.get(Calendar.YEAR);
    int mMonth = calendar.get(Calendar.MONTH);
    int mDay = calendar.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            final Calendar calendar = Calendar.getInstance();
            calendar.set(year, monthOfYear, dayOfMonth);
            listener.dateSelected(calendar.getTimeInMillis());
        }
    }, mYear, mMonth, mDay);
    dialog.setButton(DatePickerDialog.BUTTON_NEUTRAL, getString(R.string.clear),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    listener.dateSelected(null);
                }
            });
    dialog.show();
}