I have a datePicker dialog box in my application. It works great when I select a date. However, if I change the date in the dialog and then wring it out, the original edittext file remains unchanged, as it should, but the date picker still has a date earlier when it was canceled. I would like to make sure that EVERY time I go into the Date Picker, it sets the date from EditText. My code is as follows.
onCreate () Method
// Date Listener fdEtDate.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { showDialog(DATE_DIALOG_ID); return false; } });
Further down Activity
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE)); case STD_DIALOG_ID: return new TimePickerDialog(this, stdSetListener, stdHH, stdMM, true); case STA_DIALOG_ID: return new TimePickerDialog(this, staSetListener, staHH, staMM, true); } return null; }
It seems that a new dialog is created each time, so why is it not initialized every time with the date from fdEtDate (EditText)
Thank you in advance
source share