Solved

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

Posted on 2012-04-02
3
910 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:
santhanasamy 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
android app- saved password.. 7 42
egit plugin on eclipse 8 28
factorial example 4 34
configure dependency in POM for new database 3 13
Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

929 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

14 Experts available now in Live!

Get 1:1 Help Now