Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:52:50+00:00 2026-06-15T02:52:50+00:00

I have two date pickers in the same activity and they are connected to

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:52:52+00:00Added an answer on June 15, 2026 at 2:52 am

    EDIT
    If you assign a variable for listeners you can reuse them. Also it seems you have variable name clash. When OnDateChangedListener is called there is a currentYear/currentMonth/currentDay function arguments and class member variables:

    OnDateChangedListener periodListener = null;
    OnDateChangedListener birthdayListener  = null;
    
    periodListener = new OnDateChangedListener() {
             @Override
             public void onDateChanged(DatePicker periodDatePicker, int newYear, int newMonth, int newDay) {
                  Number = 1;
                  birthDayDatePicker.init(currentYear, currentMonth, currentDay, null);
                  birthDateCalculations();
                  birthDayDatePicker.init(currentYear, currentMonth, currentDay, birthdayListener);
             }
    
    
    birthdayListener = new OnDateChangedListener () {    
             @Override
             public void onDateChanged(DatePicker birthDayDatePicker, int newYear, int newMonth, int newDay) {
                  Number = 2;
                  periodDatePicker.init(currentYear, currentMonth, currentDay, null);
                  periodDateCalculations();               
                  periodDatePicker.init(currentYear, currentMonth, currentDay, periodListener);
             }
        });
    
    
    birthDayDatePicker.init(currentYear, currentMonth, currentDay, birthdayListener);
    periodDatePicker.init(currentYear, currentMonth, currentDay, periodListener);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two date pickers which are connected to each other as when I
I've got two date pickers in one form. They have different id's so this
I have two date pickers one for startDate and another one is for endDate.
I have two datepicker fields, one is ' start date ' the other is
HI i have two date pickers. datepicker1, datepicker2. I need datepicker1.date to compare with
I have two Ajax date time picker in my aspx picker.I want to have
I have two date pickers. A startdate and an enddate . The way I
I have two date picker components and a JComboBox component with their associated Action
I have two input dates taking from Date Picker control. I have selected start
I have 2 textboxes, txtStartDate.Text and txtEndDate.Text, user choose date through calendar date picker.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.