Java Code Examples for android.app.DatePickerDialog#OnDateSetListener
The following examples show how to use
android.app.DatePickerDialog#OnDateSetListener .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeFaceActivity.java From DynamicCalendar with Apache License 2.0 | 7 votes |
@Override public void onClick(View v) { mCurrentDate = Calendar.getInstance(); int mYear = mCurrentDate.get(Calendar.YEAR); int mMonth = mCurrentDate.get(Calendar.MONTH); int mDay = mCurrentDate.get(Calendar.DAY_OF_MONTH); DatePickerDialog mDatePicker = new DatePickerDialog(TypeFaceActivity.this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker datepicker, int selectedYear, int selectedMonth, int selectedDay) { // Update the editText to display the selected date mDateEditText.setText(selectedDay + "-" + (selectedMonth + 1) + "-" + selectedYear); // Set the mCurrentDate to the selected date-month-year mCurrentDate.set(selectedYear, selectedMonth, selectedDay); mGeneratedDateIcon = mImageGenerator.generateDateImage(mCurrentDate, R.drawable.empty_calendar); mDisplayGeneratedImage.setImageBitmap(mGeneratedDateIcon); } }, mYear, mMonth, mDay); mDatePicker.show(); }
Example 2
Source File: EditMovieFragment.java From Mizuu with Apache License 2.0 | 6 votes |
private void showDatePickerDialog(String initialValue) { String[] dateArray = initialValue.split("-"); Calendar cal = Calendar.getInstance(); cal.set(Integer.parseInt(dateArray[0]), Integer.parseInt(dateArray[1]) - 1, Integer.parseInt(dateArray[2])); DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // Update the date mMovie.setReleaseDate(year, monthOfYear + 1, dayOfMonth); // Update the UI with the new value setupValues(false); } }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); dialog.show(); }
Example 3
Source File: EditTvShowFragment.java From Mizuu with Apache License 2.0 | 6 votes |
private void showDatePickerDialog(String initialValue) { String[] dateArray = initialValue.split("-"); Calendar cal = Calendar.getInstance(); cal.set(Integer.parseInt(dateArray[0]), Integer.parseInt(dateArray[1]) - 1, Integer.parseInt(dateArray[2])); DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // Update the date mShow.setFirstAiredDate(year, monthOfYear + 1, dayOfMonth); // Update the UI with the new value setupValues(false); } }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); dialog.show(); }
Example 4
Source File: OCM_ChildMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
void showPickTimeDialog (final TimePickerDialog.OnTimeSetListener listener) { final DatePickerDialog.OnDateSetListener dateListener = (DatePickerDialog.OnDateSetListener) listener; final Calendar calendar = Calendar.getInstance(); TimePickerDialog d = new TimePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(MainActivity.mainActivity)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { showPickDateDialog(dateListener, null); } }); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCustomTitle(linearLayout); // d.show(); }
Example 5
Source File: NetworkUsageStatsFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
private void pickDate(final Date target) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(target); DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); target.setTime(calendar.getTimeInMillis()); updateButtonsText(); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); dialog.show(); }
Example 6
Source File: CompetitionCreatorActivity.java From 1Rramp-Android with MIT License | 6 votes |
private void showDatePicker(String msg, final EditText targetInput) { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+0")); int mYear = c.get(Calendar.YEAR); int mMonth = c.get(Calendar.MONTH); int mDay = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { if (targetInput != null) { targetInput.setText(String.format(Locale.US, "%02d-%02d-%02d", year, 1 + monthOfYear, dayOfMonth)); } } }, mYear, mMonth, mDay); datePickerDialog.setMessage(msg); datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis()); datePickerDialog.show(); }
Example 7
Source File: DynamicSettersActivity.java From calendarview2 with MIT License | 5 votes |
public static void showDatePickerDialog(Context context, CalendarDay day, DatePickerDialog.OnDateSetListener callback) { if (day == null) { day = CalendarDay.today(); } DatePickerDialog dialog = new DatePickerDialog( context, 0, callback, day.getYear(), day.getMonth(), day.getDay() ); dialog.show(); }
Example 8
Source File: EditUserInfoDetailActivity.java From TestChat with Apache License 2.0 | 5 votes |
private void openDatePicker() { CustomDatePickerDialog dialog = new CustomDatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { currentYear = year; currentMonth = month; currentDay = dayOfMonth; updateDateChanged(); } }, currentYear, currentMonth, currentDay); dialog.show(); }
Example 9
Source File: OBSetupMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
void showPickTimeDialog (final TimePickerDialog.OnTimeSetListener listener) { final DatePickerDialog.OnDateSetListener dateListener = (DatePickerDialog.OnDateSetListener) listener; final Calendar calendar = Calendar.getInstance(); TimePickerDialog d = new TimePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(MainActivity.mainActivity)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { if (screenType == ScreenType.SET_DATE_SCREEN) { showPickDateDialog(dateListener, null); } else { MainActivity.log("OBSetupMenu:showPickTimeDialog:cancelled!"); } } }); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCustomTitle(linearLayout); // d.show(); }
Example 10
Source File: Picker_Fragment.java From ui with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View myView = inflater.inflate(R.layout.picker_fragment, container, false); tv_date = myView.findViewById(R.id.tv_date); tv_time = myView.findViewById(R.id.tv_time); btn_date = myView.findViewById(R.id.btn_date); btn_date.setOnClickListener(this); btn_time = myView.findViewById(R.id.btn_time); btn_time.setOnClickListener(this); //create the date picker listener, which is used later when the picker is called. d = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateAndTime.set(Calendar.YEAR, year); dateAndTime.set(Calendar.MONTH, monthOfYear); dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); tv_date.setText(fmtDate.format(dateAndTime.getTime())); } }; //create the time picker listener t = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { dateAndTime.set(Calendar.HOUR, selectedHour); dateAndTime.set(Calendar.MINUTE, selectedMinute); // set current time into textview tv_time.setText(fmtTime.format(dateAndTime.getTime())); } }; return myView; }
Example 11
Source File: DismissableDatePickerDialog.java From react-native-GPay with MIT License | 5 votes |
public DismissableDatePickerDialog( Context context, int theme, @Nullable DatePickerDialog.OnDateSetListener callback, int year, int monthOfYear, int dayOfMonth) { super(context, theme, callback, year, monthOfYear, dayOfMonth); }
Example 12
Source File: DatePickerDialogFragment.java From white-label-event-app with Apache License 2.0 | 5 votes |
@Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Activity activity = getActivity(); if (activity instanceof DatePickerDialog.OnDateSetListener) { ((DatePickerDialog.OnDateSetListener) activity).onDateSet(view, year, monthOfYear, dayOfMonth); } }
Example 13
Source File: DynamicSettersActivity.java From material-calendarview with MIT License | 5 votes |
public static void showDatePickerDialog( Context context, CalendarDay day, DatePickerDialog.OnDateSetListener callback) { if (day == null) { day = CalendarDay.today(); } DatePickerDialog dialog = new DatePickerDialog( context, 0, callback, day.getYear(), day.getMonth() - 1, day.getDay() ); dialog.show(); }
Example 14
Source File: EventInitialPresenter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onDateClick(@Nullable DatePickerDialog.OnDateSetListener listener) { view.showDateDialog(listener); }
Example 15
Source File: CheckupReminders.java From Crimson with Apache License 2.0 | 4 votes |
private void setDateTimeField() { onDateEt.setOnClickListener(this); Calendar newCalendar = Calendar.getInstance(); onDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); onDateEt.setText(dateFormatter.format(newDate.getTime())); } }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH)); }
Example 16
Source File: EventInitialActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void showCustomCalendar(DatePickerDialog.OnDateSetListener listener) { LayoutInflater layoutInflater = LayoutInflater.from(getContext()); WidgetDatepickerBinding widgetBinding = WidgetDatepickerBinding.inflate(layoutInflater); final DatePicker datePicker = widgetBinding.widgetDatepicker; Calendar calendar = Calendar.getInstance(); if (selectedDate != null) calendar.setTime(selectedDate); if (eventCreationType == EventCreationType.SCHEDULE) calendar.add(Calendar.DAY_OF_YEAR, eventScheduleInterval); datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); if (program.expiryPeriodType() != null) { Date minDate = DateUtils.getInstance().expDate(null, program.expiryDays() == null ? 0 : program.expiryDays(), program.expiryPeriodType()); datePicker.setMinDate(minDate.getTime()); } switch (eventCreationType) { case ADDNEW: case DEFAULT: datePicker.setMaxDate(System.currentTimeMillis() - 1000); break; case REFERAL: case SCHEDULE: break; } AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext(), R.style.DatePickerTheme); alertDialog.setView(widgetBinding.getRoot()); Dialog dialog = alertDialog.create(); widgetBinding.changeCalendarButton.setOnClickListener(calendarButton -> { showNativeCalendar(listener); dialog.dismiss(); }); widgetBinding.clearButton.setOnClickListener(clearButton -> dialog.dismiss()); widgetBinding.acceptButton.setOnClickListener(acceptButton -> { listener.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()); dialog.dismiss(); }); dialog.show(); }
Example 17
Source File: DatePickerFragment.java From outlay with Apache License 2.0 | 4 votes |
public void setOnDateSetListener(DatePickerDialog.OnDateSetListener listener) { this.listener = listener; }
Example 18
Source File: LauncherActivity.java From android-apps with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); listView = (ListView) findViewById(R.id.doctorPlanList); lblDate = (TextView) findViewById(R.id.tvDoctorPlanDate); btnSavePlan = (Button) findViewById(R.id.btnSavePlan); //btnSavePlan.setOnClickListener(this); // radioGroupShift = (RadioGroup) // rootView.findViewById(R.id.radioShift); String myFormat = "dd/MM/yyyy EEEE"; // In which you need put here SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US); lblDate.setText(sdf.format(myCalendar.getTime())); planDate = getCurrentMillisecond(myCalendar); DoctorVisit.DOCTOR_PLAN_LIST = DemoData.getDoctorSortList(); doctorPlanAdapter = new DoctorPlanAdapter(this, DoctorVisit.DOCTOR_PLAN_LIST); listView.setAdapter(doctorPlanAdapter); plannedDate = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub myCalendar.set(Calendar.YEAR, year); myCalendar.set(Calendar.MONTH, monthOfYear); myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); updateLabel(); doctorPlanAdapter.notifyDataSetChanged(); } }; //lblDate.setOnClickListener(this); configFirstnLastDate(); }
Example 19
Source File: DatePickerFragment.java From googleads-mobile-android-examples with Apache License 2.0 | 4 votes |
public void setOnDateSetListener(DatePickerDialog.OnDateSetListener listener) { onDateSetListener = listener; }
Example 20
Source File: EventInitialContract.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | votes |
void showDateDialog(DatePickerDialog.OnDateSetListener listener);