I have an activity with 2 EditText (startDate and endDate).
I have created a function that i pass it an EditText and it will show a DatePicker:
private void showDatePicker(EditText et) {
Calendar calendar = Calendar.getInstance();
DatePickerDialog picker = new DatePickerDialog(getActivity(), this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
if (!Global.isEmpty(et)) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(Global.USER_FRIENDLY_DATE_FORMAT, Locale.getDefault());
calendar.setTime(sdf.parse(et.getText().toString()));
} catch (ParseException e) {
Toast.makeText(getActivity(), "Error setting the date", Toast.LENGTH_SHORT).show();
}
}
picker.show();
}
When i pick a date, i will get a callback to the onDateSet() function with the date choosen.
My questions is, how can i tell for which EditText it is?
I know there is a "DatePicker view" that is passed as an argument to the onDateSet(), but cannot seem to figure out how to use it or even if i should.