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 9141475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:38:59+00:00 2026-06-17T09:38:59+00:00

I am creating a DatePickerDialog , like it’s done in the documentation . However,

  • 0

I am creating a DatePickerDialog, like it’s done in the documentation. However, I am noticing that the CalendarView‘s title (i.e. “December 2012” as it would be for today) doesn’t change immediately when the year is set in the Spinners. I see that the weeks are changed correctly, and I can set the title on the dialog based on the onSelectedDayChange callback with the appropriate date (month, month day, year, week day). Furthermore, if the month is changed in the Spinners, then the CalendarView is updated immediately. This includes, correctly showing the selected year if the year was changed before the month was changed. And if the CalendarView is scrolled to other months the year also gets adjusted to show the correct year.

This seems to imply that the CalendarView simply isn’t redrawing the title (probably optimization?) when the date is getting set. Am I doing something else wrong? Is there a solution to this? Or is it a bug in the implementation?

Here’s my code:

public class DatePickerFragment extends DialogFragment
    implements DatePickerDialog.OnDateSetListener {
    /** Name of the date stored in a {@link Bundle} */
    public static final String KEY_DATE = "key.DatePickerFragment.DATE";

    @Override
    public Dialog onCreateDialog(Bundle icicle) {
        final Bundle arguments = getArguments();
        Time date = arguments == null
                ? TimeMachine.getTimeFromArray(getArguments().getIntArray(KEY_DATE))
                : null;

        if (date == null)
            date = TimeMachine.getToday();

        _dialog_window = new DatePickerDialog(getActivity(), this, date.year, date.month, date.monthDay);
        final CalendarView calendar_view = _dialog_window.getDatePicker().getCalendarView();
        calendar_view.setOnDateChangeListener(
                new CalendarView.OnDateChangeListener() {
                    @Override
                    public void onSelectedDayChange(CalendarView _, int year, int month, int day) {
                        updateTitle(TimeMachine.getTimeFromArray(new int[]{ year, month, day }));
                    }
                }
        );

        // Sets the title
        updateTitle(date);

        // Create a new instance of DatePickerDialog and return it
        return _dialog_window;
    }

    @Override
    public void onDateSet(DatePicker _, int year, int month, int day) {
        final Time date = new Time();
        date.set(day, month, year);
    }

    private void updateTitle(Time date) {        
        _dialog_window.setTitle(date.format(" %A,  %B %e, %Y"));
    }

    /** The Dialog window */
    private DatePickerDialog _dialog_window;
}
  • 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-17T09:39:00+00:00Added an answer on June 17, 2026 at 9:39 am

    Seeing as there aren’t others coming forth with any other answer, I got around this problem by not enabling the CalendarView on the DatePicker, and instead making a custom DialogFragment that had a numerical date picker and a separate CalendarView (actually my own reimplementation based on the real CalendarView to allow tweaks to it’s display and Otto event bus). Then I can make sure that the CalendarView is set each time the numeric date picker is set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
Creating a browser based single-page browser based RIA. Would like to make use of
Creating a Drawable that is completely empty seems like a common need, as a
creating a small web application to be deployed on Heroku, where we would like
I'm creating button dynamically at runtime which their click event opens a datepickerdialog. So
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating an accordion - on the slide - the elements underneath the element that
Creating a C# install package and I'd like on completed install for the Program
In short, I'm working on a DurationPickerDialog that works similarly to how the DatePickerDialog

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.