@Override public void onClick(DialogInterface dialog, int which) { try { if (dialog.getClass() != DateTimePickerDialog.class) { return; } switch (which) { case DialogInterface.BUTTON_POSITIVE: DateTimePickerDialog reminderDl = (DateTimePickerDialog) dialog; Date date = reminderDl.getDate(); txt_date.setText(Helper.dateToString(date, Helper.NORMAL_DAY_OF_WEEK_FORMAT)); break; case DialogInterface.BUTTON_NEGATIVE: txt_date.setText("Set Date time please!"); break; default: break; } } catch (Exception ex) { Log.e("MainActivity", ex.getMessage()); } }
public void showReminderPicker() { // LayoutInflater inflater = (LayoutInflater) getLayoutInflater(); // View customView = inflater.inflate(R.layout.reminder_picker, null); DateTimePickerDialog dtpDialog = new DateTimePickerDialog(MainActivity.this); dtpDialog.setIcon(R.drawable.alarm); Calendar c = Calendar.getInstance(); dtpDialog.setDateTime(c); dtpDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Save", dialog_onclick); dtpDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Remove", dialog_onclick); dtpDialog.show(); }