I have two date pickers in the same activity and they are connected to each other, as when the user change one date the other date picker date is changed directly
Here are the listeners
//initialize period date picker with current date and on date change listener
periodDatePicker.init(currentYear, currentMonth, currentDay, new OnDateChangedListener()
{
@Override
public void onDateChanged(DatePicker periodDatePicker, int currentYear, int currentMonth,int currentDay) {
// TODO Auto-generated method stub
Number = 1;
birthDayDatePicker.init(currentYear, currentMonth, currentDay, null);
birthDateCalculations();
}
});
//initialize birth date picker with current date and on date change listener
birthDayDatePicker.init(currentYear, currentMonth, currentDay, new OnDateChangedListener () {
@Override
public void onDateChanged(DatePicker birthDayDatePicker, int currentYear, int currentMonth, int currentDay) {
// TODO Auto-generated method stub
Number = 2;
periodDatePicker.init(currentYear, currentMonth, currentDay, null);
periodDateCalculations();
}
});
when one date picker listener is invoked , I turn the other listener to the second date picker to null , my question is, how can I make the listener that I turned to null to be active again
EDIT
If you assign a variable for listeners you can reuse them. Also it seems you have variable name clash. When
OnDateChangedListeneris called there is acurrentYear/currentMonth/currentDayfunction arguments and class member variables: