Example usage for android.app DatePickerDialog DatePickerDialog

List of usage examples for android.app DatePickerDialog DatePickerDialog

Introduction

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

Prototype

public DatePickerDialog(@NonNull Context context, @Nullable OnDateSetListener listener, int year, int month,
        int dayOfMonth) 

Source Link

Document

Creates a new date picker dialog for the specified date using the parent context's default date picker dialog theme.

Usage

From source file:com.clerton.leal.tracker.fragment.DatePickerFragment.java

License:asdf

 @Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
   final Calendar calendar = Calendar.getInstance();
   final int year = calendar.get(Calendar.YEAR);
   final int month = calendar.get(Caleasdfasdfdar.MONTH);
   final int day = calendar.get(Calendar.DAY_OF_MONTH);

   // Set actual date by defaultsdfasdf
   return new DatePickerDialog(getActivity(), onDateSetListener, year, month, day);
}

From source file:com.googlecode.networklog.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new DatePickerDialog(getActivity(), this.listener, this.year, this.month, this.day);
}

From source file:com.collabora.xwperf.notxw_contacts.fragments.DatePickerFragment.java

@NonNull
@Override/*from   w  w  w. jav  a  2  s . c  o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date(getArguments().getLong(EXTRA_INIT_DATE)));
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    dialog.getDatePicker().setMaxDate(new Date().getTime() + 1);
    return dialog;
}

From source file:au.org.ala.fielddata.mobile.ui.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);
    return new DatePickerDialog(getActivity(), this, year, month, day);
}

From source file:com.googlecode.android_scripting.facade.ui.DatePickerDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    mDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker view, int year, int month, int day) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "positive");
                result.put("year", year);
                result.put("month", month + 1);
                result.put("day", day);
                setResult(result);/*from   ww w. j a va2s  .c  o  m*/
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    }, mYear, mMonth, mDay);
    mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface view) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "neutral");
                result.put("year", mYear);
                result.put("month", mMonth + 1);
                result.put("day", mDay);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "negative");
                result.put("year", mYear);
                result.put("month", mMonth + 1);
                result.put("day", mDay);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.show();
    mShowLatch.countDown();
}

From source file:uk.co.tekkies.readings.fragment.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), onDateSetListener, year, month, day);
}

From source file:com.kyleszombathy.sms_scheduler.DatePickerFragment.java

@NonNull
@Override//from w  ww  . j av a 2  s . co  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
    return dialog;
}

From source file:com.google.android.gms.example.apidemo.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar calendar = Calendar.getInstance();

    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), mOnDateSetListener, year, month, day);
}

From source file:com.procleus.brime.ui.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    return new DatePickerDialog(getActivity(), this, year, month, day);
}

From source file:com.stephenmcgruer.threethingstoday.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), mOnDateSetListener, mInitialYear,
            mInitialMonth, mInitialDayOfMonth);

    // Disallow future dates. For Lollipop, we need to set the timestamp to the last second
    // of the last allowed day, or that day will be visible but not selectable.
    // TODO(smcgruer): I don't think this actually works. Need to test on real device.
    final Calendar maxCal = Calendar.getInstance();
    maxCal.set(Calendar.HOUR, 23);
    maxCal.set(Calendar.MINUTE, 59);
    maxCal.set(Calendar.SECOND, 59);
    dialog.getDatePicker().setMaxDate(maxCal.getTimeInMillis());

    return dialog;
}