Example usage for android.app DatePickerDialog setTitle

List of usage examples for android.app DatePickerDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.saulcintero.moveon.ui.widgets.myDatePickerDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dp = new DatePickerDialog(getActivity(), ondateSet, year, month, day);
    dp.setTitle(title);
    return dp;//from   w w  w. jav  a2  s .com
}

From source file:it.feio.android.omninotes.utils.date.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Use the current date as the default date in the picker
    Calendar cal = DateHelper.getCalendar(defaultDate);
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    int day = cal.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog dpd = new DatePickerDialog(mActivity, R.style.Theme_AppCompat_Dialog_NoBackgroundOrDim,
            mListener, year, month, day);
    dpd.setTitle("");
    return dpd;// w w w .  ja  v a 2  s.c o  m
}

From source file:com.dycody.android.idealnote.utils.date.DatePickerDialogFragment.java

@NonNull
@Override/*from   www.  j  a  v  a  2s  .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    Calendar cal = DateUtils.getCalendar(defaultDate);
    int y = cal.get(Calendar.YEAR);
    int m = cal.get(Calendar.MONTH);
    int d = cal.get(Calendar.DAY_OF_MONTH);

    // Jelly Bean introduced a bug in DatePickerDialog (and possibly 
    // TimePickerDialog as well), and one of the possible solutions is 
    // to postpone the creation of both the listener and the BUTTON_* .
    // 
    // Passing a null here won't harm because DatePickerDialog checks for a null
    // whenever it reads the listener that was passed here. >>> This seems to be 
    // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now.
    //
    // See my own question and answer, and details I included for the issue:
    //
    // http://stackoverflow.com/a/11493752/489607
    // http://code.google.com/p/android/issues/detail?id=34833
    //
    // Of course, suggestions welcome.

    final DatePickerDialog picker = new DatePickerDialog(getActivity(), DatePickerDialog.THEME_HOLO_LIGHT,
            getConstructorListener(), y, m, d);
    picker.setTitle("");

    if (hasJellyBeanAndAbove()) {
        picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        DatePicker dp = picker.getDatePicker();
                        mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
                    }
                });
        picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
    }

    return picker;
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showEndsOnDateDialog() {
    Calendar endDateCalendar = Calendar.getInstance();
    endDateCalendar.setTime(endDate);//w w w  . j a  v  a2s.  c o m

    OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {

        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            endDate = DateUtils.setYears(endDate, year);
            endDate = DateUtils.setMonths(endDate, monthOfYear);
            endDate = DateUtils.setDays(endDate, dayOfMonth);
            updateEndDateButtons();
        }
    };

    DatePickerDialog datePickerDialog = new DatePickerDialog(context, onDateSetListener,
            endDateCalendar.get(Calendar.YEAR), endDateCalendar.get(Calendar.MONTH),
            endDateCalendar.get(Calendar.DAY_OF_MONTH));
    datePickerDialog.setTitle(R.string.activity_edit_event_pick_end_date);
    datePickerDialog.show();
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showStartsOnDateDialog() {
    Calendar startDateCalendar = Calendar.getInstance();
    startDateCalendar.setTime(startDate);

    OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {

        @Override//from  w  w w.  j  a  v a 2  s  .co m
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            long diff = endDate.getTime() - startDate.getTime();

            startDate = DateUtils.setYears(startDate, year);
            startDate = DateUtils.setMonths(startDate, monthOfYear);
            startDate = DateUtils.setDays(startDate, dayOfMonth);
            updateStartDateButtons();

            endDate.setTime(startDate.getTime() + diff);
            updateEndDateButtons();
        }
    };

    DatePickerDialog datePickerDialog = new DatePickerDialog(context, onDateSetListener,
            startDateCalendar.get(Calendar.YEAR), startDateCalendar.get(Calendar.MONTH),
            startDateCalendar.get(Calendar.DAY_OF_MONTH));
    datePickerDialog.setTitle(R.string.activity_edit_event_pick_start_date);
    datePickerDialog.show();
}

From source file:org.openmrs.mobile.activities.addeditpatient.AddEditPatientFragment.java

private void addListeners() {
    gen.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup rGroup, int checkedId) {
            gendererror.setVisibility(View.GONE);
        }/* w w  w  .j  av  a 2  s.c om*/
    });

    edcountry.setThreshold(2);
    edcountry.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (edcountry.getText().length() >= edcountry.getThreshold()) {
                edcountry.showDropDown();
            }
            if (Arrays.asList(countries).contains(edcountry.getText().toString())) {
                edcountry.dismissDropDown();
            }
        }
    });
    edstate.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            addSuggestionsToCities();
        }
    });
    if (eddob != null) {
        eddob.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int cYear;
                int cMonth;
                int cDay;

                if (bdt == null) {
                    Calendar currentDate = Calendar.getInstance();
                    cYear = currentDate.get(Calendar.YEAR);
                    cMonth = currentDate.get(Calendar.MONTH);
                    cDay = currentDate.get(Calendar.DAY_OF_MONTH);
                } else {
                    cYear = bdt.getYear();
                    cMonth = bdt.getMonthOfYear() - 1;
                    cDay = bdt.getDayOfMonth();
                }

                edmonth.getText().clear();
                edyr.getText().clear();

                DatePickerDialog mDatePicker = new DatePickerDialog(AddEditPatientFragment.this.getActivity(),
                        new DatePickerDialog.OnDateSetListener() {
                            public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth,
                                    int selectedday) {
                                int adjustedMonth = selectedmonth + 1;
                                eddob.setText(selectedday + "/" + adjustedMonth + "/" + selectedyear);
                                birthdate = new LocalDate(selectedyear, adjustedMonth, selectedday);
                                bdt = birthdate.toDateTimeAtStartOfDay().toDateTime();
                            }
                        }, cYear, cMonth, cDay);
                mDatePicker.getDatePicker().setMaxDate(System.currentTimeMillis());
                mDatePicker.setTitle("Select Date");
                mDatePicker.show();
            }
        });
    }

    capturePhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AddEditPatientFragmentPermissionsDispatcher.capturePhotoWithCheck(AddEditPatientFragment.this);
        }
    });

    submitConfirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPresenter.confirmRegister(createPatient());
        }
    });

    patientImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (output != null) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setDataAndType(Uri.fromFile(output), "image/jpeg");
                startActivity(i);
            } else if (patientPhoto != null) {
                Intent intent = new Intent(getContext(), PatientPhotoActivity.class);
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                patientPhoto.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
                intent.putExtra("photo", byteArrayOutputStream.toByteArray());
                intent.putExtra("name", patientName);
                startActivity(intent);
            }
        }
    });

    TextWatcher textWatcher = new PatientBirthdateValidatorWatcher(eddob, edmonth, edyr);
    edmonth.addTextChangedListener(textWatcher);
    edyr.addTextChangedListener(textWatcher);
}

From source file:dev.memento.MementoBrowser.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    switch (id) {
    case DIALOG_DATE:
        // To fix a bug described here: http://www.zunisoft.com/?p=1140 
        DatePickerDialog dlg = (DatePickerDialog) dialog;
        DateFormat longDateFormat = new SimpleDateFormat("EEEE, MMMM d, yyyy");
        dlg.setTitle(longDateFormat.format(mDateChosen.getDate()));
        dlg.updateDate(mDateChosen.getYear(), mDateChosen.getMonth() - 1, mDateChosen.getDay());
        break;//from   w w w  .ja v a 2  s .  co  m
    case DIALOG_ERROR:
        AlertDialog ad = (AlertDialog) dialog;
        ad.setMessage(mErrorMessage);
        mErrorMessage = null;
        break;
    }
}

From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
        boolean brokenSamsungDevice = isBrokenSamsungDevice();
        @SuppressLint("InlinedApi")
        Context context = brokenSamsungDevice ? new ContextThemeWrapper(this,
                MyApplication.getThemeType() == MyApplication.ThemeType.dark ? android.R.style.Theme_Holo_Dialog
                        : android.R.style.Theme_Holo_Light_Dialog)
                : this;
        int year = mCalendar.get(Calendar.YEAR);
        int month = mCalendar.get(Calendar.MONTH);
        int day = mCalendar.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog datePickerDialog = new DatePickerDialog(context, mDateSetListener, year, month, day);
        if (brokenSamsungDevice) {
            datePickerDialog.setTitle("");
            datePickerDialog.updateDate(year, month, day);
        }/*from w  w  w. j  a  v  a 2  s  . c  om*/
        return datePickerDialog;
    case TIME_DIALOG_ID:
        return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR_OF_DAY),
                mCalendar.get(Calendar.MINUTE), android.text.format.DateFormat.is24HourFormat(this));
    }
    return null;
}

From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.notification:
        Fragment frag = getActivity().getSupportFragmentManager().findFragmentByTag("notPrefs");
        if (frag == null) {
            ((Main) getActivity()).setFooterText("", false);
            getActivity().getSupportFragmentManager().beginTransaction()
                    .add(R.id.fragContainer, NotificationPrefs.create(mTimes), "notPrefs")
                    .commitAllowingStateLoss();
        } else {//from   ww w. j av  a 2 s  .c  o m
            ((Main) getActivity()).setFooterText(getString(R.string.monthly), true);
            getActivity().getSupportFragmentManager().beginTransaction().remove(frag).commitAllowingStateLoss();

        }

        break;
    case R.id.export:
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.export).setItems(new CharSequence[] { "CSV", "PDF" },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, final int which) {

                        long minDate = 0;
                        long maxDate = Long.MAX_VALUE;
                        if (mTimes instanceof WebTimes) {
                            minDate = ((WebTimes) mTimes).getFirstSyncedDay().toDateTimeAtCurrentTime()
                                    .getMillis();
                            maxDate = ((WebTimes) mTimes).getLastSyncedDay().toDateTimeAtCurrentTime()
                                    .getMillis();
                        }
                        final LocalDate ld = LocalDate.now();
                        final long finalMaxDate = maxDate;
                        DatePickerDialog dlg = new DatePickerDialog(getActivity(),
                                new DatePickerDialog.OnDateSetListener() {
                                    @Override
                                    public void onDateSet(DatePicker datePicker, int y, int m, int d) {
                                        final LocalDate from = new LocalDate(y, m + 1, d);
                                        DatePickerDialog dlg = new DatePickerDialog(getActivity(),
                                                new DatePickerDialog.OnDateSetListener() {
                                                    @Override
                                                    public void onDateSet(DatePicker datePicker, int y, int m,
                                                            int d) {
                                                        final LocalDate to = new LocalDate(y, m + 1, d);
                                                        try {
                                                            export(which, from, to);
                                                        } catch (IOException e) {
                                                            e.printStackTrace();
                                                            Crashlytics.logException(e);
                                                            Toast.makeText(getActivity(), R.string.error,
                                                                    Toast.LENGTH_SHORT).show();
                                                        }
                                                    }
                                                }, ld.getYear(), ld.getMonthOfYear() - 1, ld.getDayOfMonth());
                                        DateTime startDate = DateTime.now().withDate(y, m + 1, d);
                                        long start = startDate.getMillis();
                                        dlg.getDatePicker().setMinDate(start);
                                        if (which == 1)
                                            dlg.getDatePicker().setMaxDate(
                                                    Math.min(finalMaxDate, startDate.plusDays(31).getMillis()));
                                        else
                                            dlg.getDatePicker().setMaxDate(finalMaxDate);
                                        dlg.setTitle(R.string.to);
                                        dlg.show();

                                    }
                                }, ld.getYear(), ld.getMonthOfYear() - 1, ld.getDayOfMonth());
                        dlg.getDatePicker().setMinDate(minDate);
                        dlg.getDatePicker().setMaxDate(maxDate);
                        dlg.setTitle(R.string.from);
                        dlg.show();
                    }
                });
        builder.show();
        break;
    case R.id.refresh:
        if (mTimes instanceof WebTimes) {
            ((WebTimes) mTimes).syncAsync();
        }
        break;

    case R.id.share:
        String txt = getString(R.string.shareTimes, mTimes.getName()) + ":";
        LocalDate date = LocalDate.now();
        String[] times = { mTimes.getTime(date, 0), mTimes.getTime(date, 1), mTimes.getTime(date, 2),
                mTimes.getTime(date, 3), mTimes.getTime(date, 4), mTimes.getTime(date, 5) };
        for (int i = 0; i < times.length; i++) {
            txt += "\n   " + Vakit.getByIndex(i).getString() + ": " + times[i];
        }

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
        sharingIntent.putExtra(Intent.EXTRA_TEXT, txt);
        startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share)));

    }
    return super.onOptionsItemSelected(item);
}