When I click edittext, date picker dialog opens. without clicking done button in date picker and clicked outside of dialog, it sets in edittext.
I checked this but this works for first time. When selecting second time by choosing dialog and without clicking done button, it fails.
private final DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
private boolean fired;
public void resetFired(){
fired = false;
}
@Override
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
if (fired) {
Log.e("DatePicker", "Ignoring for first time");
birthDayValue = selectedDay;
birthMonthValue = selectedMonth;
birthYearValue = selectedYear;
String birthDayDateFormt = Utils.getBirthDayDate(selectedYear,
selectedMonth, selectedDay);
dateOfBirth.setText(birthDayDateFormt);
dateOfBirth.setError(null);
return;//ignore and return.
}
fired = true;//first time fired
}
};
};
How to solve this issue?
if(view.isShown()) add code in this condition, its a simple step do it and check output