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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:48:27+00:00 2026-06-13T11:48:27+00:00

I have a problem when I’m trying to set DatePickerDialog title permanently. DatePickerFragment.java public

  • 0

I have a problem when I’m trying to set DatePickerDialog title permanently.

DatePickerFragment.java

public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog dpd = new DatePickerDialog(getActivity(), this, year, month, day);
    dpd.setTitle("set date");
    return dpd;
    }

    public void onDateSet(DatePicker view, int year, int month, int day) {
    // Do something with the date chosen by the user
    }
}

MainActivity.java

public class MainActivity extends FragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn = (Button) findViewById(R.id.button1);

        btn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                DialogFragment newFragment = new DatePickerFragment();
                newFragment.show(getSupportFragmentManager(), "datePicker");

            }
        });
    }
}

When I click button DatePickerDialog shows and dialog title is “set date” but when I change date, title contains selected date rather than “set date”. How can I set this dialog title permanently?

Tested on API 8-10.

Thank you in advance and sorry for my English. Patrick

  • 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-13T11:48:28+00:00Added an answer on June 13, 2026 at 11:48 am

    How about extending DatePickerDialog and adding a setPermanentTitle method to store a permanent title that will be forced when date gets changed ?

    public class MyDatePickerDialog extends DatePickerDialog {
    
        private CharSequence title;
    
        public MyDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
            super(context, callBack, year, monthOfYear, dayOfMonth);
        }
    
        public void setPermanentTitle(CharSequence title) {
            this.title = title;
            setTitle(title);
        }
    
        @Override
        public void onDateChanged(DatePicker view, int year, int month, int day) {
            super.onDateChanged(view, year, month, day);
            setTitle(title);
        }
    }
    

    And then use the new setPermanentTitle method:

        MyDatePickerDialog dpd = new MyDatePickerDialog(this, null, 2012, 10, 10);
        dpd.setPermanentTitle("set date");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with context menu. I have got: @Override public void onCreateContextMenu(ContextMenu menu,
I have problem in my PHP code. I'm trying to make internet shop and
I have problem with consuming DbContext class in EF 4.3 CodeFirst approach. As for
I have problem when I try to set a background to .header - nothing
I have problem to find a good namespace design and class order. Imagine we
I have problem running a Java RCP application via Java Webstart. This works for
I have problem in C#. I have a list box and a class called
I have problem with configuring NODE.JS. I was trying to install node.js with this
I have problem with declaration of variable. iam trying to prepare code using Multi
I have problem compiling this java file. I cant understand what that problem is.

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.