Solved

Android Java DatePickerDialog. How do I set the initial date value?

Posted on 2012-04-02
3
908 Views
Last Modified: 2012-04-02
This is hopefully a simple one.  I've been looking for ages but just can't find a solution.

I'm using showDialog to pop up the DatePickerDialog.  All aspects of this are fine.

I can't find out how to set the initial value the DatePickerDialog shows.  

I know you can set the value once in the onCreateDialog but I need to set it every time I show the dialog not just when its created.

I'm guessing there is some kind of object I can access I just can't find it anywhere.

Many Thanks
0
Comment
Question by:SamSherwin
3 Comments
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 250 total points
Comment Utility
first of all, you have updateDate().
then, onPrepareDialog() is called every time you use showDialog()
0
 
LVL 8

Accepted Solution

by:
santhanasamy earned 250 total points
Comment Utility
Hi  SamSherwin,

Refer this from android docs
http://developer.android.com/guide/topics/ui/dialogs.html

Before the dialog is displayed, Android also calls the optional callback method onPrepareDialog(int, Dialog). Define this method if you want to change any properties of the dialog each time it is opened. This method is called every time a dialog is opened, whereas onCreateDialog(int) is only called the very first time a dialog is opened. If you don't define onPrepareDialog(), then the dialog will remain the same as it was the previous time it was opened. This method is also passed the dialog's ID, along with the Dialog object you created in onCreateDialog().
0
 

Author Closing Comment

by:SamSherwin
Comment Utility
Thanks for the quick and good solution(s).  Sometimes when under pressure you just can see the wood for the trees.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
If your app took Google’s lash recently, here are the 5 most likely reasons.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now