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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:43:38+00:00 2026-06-05T16:43:38+00:00

So I have been at this for a while, and I cannot seem to

  • 0

So I have been at this for a while, and I cannot seem to figure it out. I am fairly new at Android development, so bear with me please. I wasn’t too familiar with creating a Datepicker and I learned to do it the deprecated way just to get the hang of it. Used this tutorial to get me up to speed:

http://developer.android.com/resources/tutorials/views/hello-datepicker.html

But now I need to change it, mainly to not use deprecated code, so I looked all around, and I found 2 tutorials, mainly this one though:

http://www.kylebeal.com/2011/11/android-datepickerdialog-and-the-dialogfragment/

Problem is, there is code that does not make sense. Mainly this part:

//create new DateDialogFragment
DateDialogFragment ddf = DateDialogFragment.newInstance(this, R.string.set_date, date);

ddf.setDateDialogFragmentListener(new DateDialogFragmentListener() {

    @Override
    public void dateDialogFragmentDateSet(Calendar date) {
        // update the fragment
        mDateDetailFragment.updateDate(date);
    }
});

ddf.show(getSupportFragmentManager(), "date picker dialog fragment");

That is suppose to be what is running in the activity class that it runs in. So I kind of get whats happening throughout the rest of the code, and feel free to look at the rest as it will probably help. The code is essentially following almost the same route as the original showDialog() code. Implementing DatePickerDialog.onDateSetListener, and returning a new DatePickerDialog, with the obvious exception thats its using a DialogFragment. But that is where I have gotten lost.

Part of the reason is because I am not really sure where onCreateDialog() returns that new DatePickerDialog. If you look at the code I said does not make sense, both mDateDetailFragment and getSupportFragmentManager() were never instantiated or appeared anywhere else, so I cannot get the tutorial code to even work. The Android Doc also mentions that instead of using showDialog() I should be using both DialogFragment and FragmentManager, which is also not done here. Only DialogFragment.

So like the title, how exactly can I make a DatPicker in the non-depracted form? I would please ask to NOT send me to a link and just say look here. I have done that. Believe me. If not, at least explain what I have missed that makes this make sense. Also, if anyone can actually tell me where the onCreateDialog() method sends the DatePickerDialog, that would be extremely helpful as well. I am just trying to make sense of all this, rather than copy and paste code (not that it works anyways). Thanks a lot for taking the time out to read this, and if any clarifications needed, please ask.

  • 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-05T16:43:39+00:00Added an answer on June 5, 2026 at 4:43 pm

    Going in order of your post… \

    1) the onCreateDialog returns the dialog to the DialogFragment.

    2) I don’t know about the mDateDetailFragment.updateDate(date); line… I think he might have left some code out. EDIT Found it, it’s in one of the classes in the zip file for his complete demo.

    3) You are using the fragment manager (it’s the getSupportFragmentManager() part):

    ddf.show(getSupportFragmentManager(), "date picker dialog fragment");
    

    Ok, that said, here’s how I’ve done it (I’m using a DateSlider, but subbing in a Datepicker in it’s place should be simple enough for you).

    In the fragment/activity calling the DialogFragment:

    DialogFragment newFragment = new DateDialog();
    newFragment.show(getFragmentManager(), "dialog"); 
    

    And my DialogFragment:

    public class DateDialog extends DialogFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
        }
        private DateSlider.OnDateSetListener mDateSetListener = new DateSlider.OnDateSetListener() {
            public void onDateSet(DateSlider view, Calendar selectedDate) {
                MemberAddFragment.startTxt.setText(String.format("%tB %te, %tY", selectedDate, selectedDate, selectedDate));
            }
        };
    
        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            final Calendar c = Calendar.getInstance();  // Get calendar instance to use in DateSlider
            return new AlternativeDateSlider(getActivity(),mDateSetListener,c,null,null);  // return DateSlider dialog to DialogFragment
        }
    }
    

    Hope this helps clear up your confusion.

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

Sidebar

Related Questions

I have been working on this for a while and cannot seem to figure
I have been having this issue for a while now and I cannot seem
I have been stuck on this for a while now and I cannot seem
I've been scratching my head on this one for a while and cannot seem
I've been trying to crack this nut for a while but I cannot seem
Still learning JSP Web Applications here. I have been doing this for a while
I have been using this copy method for quite a while, in lots of
I have been stuck on this for a while. i have tried and I
I have been working on this problem for a while now. I am trying
I have been bashing my head against this for a while now and need

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.