package com.example.download;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.Toast;

public class DateDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Calendar calendar = Calendar.getInstance();
        Dialog dialog = new DatePickerDialog(getActivity(),
                new DateListener(), 
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH));
        return dialog;
    }

    class DateListener implements DatePickerDialog.OnDateSetListener {
        @Override
        public void onDateSet(DatePicker view, int year,
                int monthOfYear, int dayOfMonth) {
            String date = (monthOfYear + 1) + "/" + dayOfMonth + "/"
                    + year;
            Toast.makeText(getActivity(), date, Toast.LENGTH_SHORT)
                    .show();
        }
    }
}