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

  • SEARCH
  • Home
  • 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 6109463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:27+00:00 2026-05-23T14:24:27+00:00

in my application i have to date picker as From date and To date.

  • 0

in my application i have to date picker as From date and To date. I am using onCreateDialog() method. So first time i am selecting the dates from date picker and putting them in the edit text. then when again i am selecting the date from the date picker, in the date picker it is showing the date which i already selected. But if i move to other search in the same screen(Activity) and try to pick the date from date picker, date picker still is showing the previous date. not the current date.

protected Dialog onCreateDialog(int id) {
    final Calendar c = Calendar.getInstance();
    switch (id) {
    case DATE_DIALOG_ID1:
        return new DatePickerDialog(this, mDateSetListener,  c.get(Calendar.YEAR),
                c.get(Calendar.MONTH),  c.get(Calendar.DAY_OF_MONTH));


    case DATE_DIALOG_ID2:
        return new DatePickerDialog(this, mDateSetListener2,  c.get(Calendar.YEAR),
                c.get(Calendar.MONTH),  c.get(Calendar.DAY_OF_MONTH));
    }
    return null;
}
  • 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-05-23T14:24:27+00:00Added an answer on May 23, 2026 at 2:24 pm

    May be you can try writing your question clearly once again, but to my understanding of your question you might want to look at your onDateChanged() callback method. I assume you have a updateDialog() method inside this onDateChanged(), you might want to check that method for err’s.

    I suppose you looked this link where they showed how to use a date picker http://developer.android.com/resources/tutorials/views/hello-datepicker.html

    good luck

    For the 2nd question you asked about mixup in from and to date dialog

    From what you are saying, I think there something like a small error like

    1) R.id.datepicker2 being used in place of R.id.datepicker1

    or

    2) having mixs up in onDateChangedListener(). I am sure there is better way to do it, but try checking whether you have like this below 2 different listeners

    final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);    
    
    
    
    DatePicker fromDatePicker = (DatePicker) findViewById(R.id.datePicker1);
        datePicker.init(mYear, mMonth, mDay, new OnDateChangedListener() {
    
            @Override
            public void onDateChanged(DatePicker view, int year,
                    int monthOfYear, int dayOfMonth) {
                //things you want to happen when datepicker1 is changed in your case the From date field     
    
    
            }
        });
    
    DatePicker toDatePicker = (DatePicker) findViewById(R.id.datePicker1);
        datePicker.init(mYear, mMonth, mDay, new OnDateChangedListener() {
    
            @Override
            public void onDateChanged(DatePicker view, int year,
                    int monthOfYear, int dayOfMonth) {
                //things you want to happen when datepicker2 is changed in your case the To date field     
    
    
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application , I have to get date from the user. First I
I have a date picker and 4 time pickers in my application. I want
We have an application parsing date/time values in the following format: 2009-10-10 09:19:12.124 2009-10-10
I have an application that has a UILabel displaying the current date and time,
I have an application that can filter a datagridview based on date using a
I have a windows phone 7 application where I´m using a DatePicker from the
For my application, I have to get a date from the user. I have
I am using datimepicker (from: http://trentrichardson.com/examples/timepicker/ ) however I cannot save the picket date-time
I have created a date picker programatically in my application . when i select
I have a requirement to use date picker in my applicaiton. I have lot

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.