I'm using two datepicker dialog, one for the start date and the other is for the end date.
The start date dialog works fine, but when I try to execute the second dialog which is the end date, end date dialog also shows up twice.
private void startDateDialog() {
// Process to get Current Date
final Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
startDate = "" + year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
endDateDialog();
}
}, mYear, mMonth, mDay);
dpd.setTitle("Start Date");
dpd.show();
}
private void endDateDialog() {
// Process to get Current Date
final Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
if (dialog == true) {
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
startDate = "" + year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
InitializeMap();
dialog = false;
}
}, mYear, mMonth, mDay);
dpd.setTitle("End Date");
dpd.show();
} else {
}
}