Solved

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

Posted on 2012-04-02
3
912 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
ID: 37796120
first of all, you have updateDate().
then, onPrepareDialog() is called every time you use showDialog()
0
 
LVL 8

Accepted Solution

by:
Santhana earned 250 total points
ID: 37796225
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
ID: 37796255
Thanks for the quick and good solution(s).  Sometimes when under pressure you just can see the wood for the trees.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb on wildfly 5 30
Cell phone carriers with unlimited data coverage 3 24
web project error add remove 1 28
moto 4g plus phone micro sd card 3 11
Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

856 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