O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code the DatePicker Dialog

The DatePicker dialog is a window that opens when the user presses the Change button. A custom dialog requires both a layout, which you have already created, and a class that contains the code that gives the dialog its behavior. Using a custom dialog in an activity also requires changes to the activity code. The following describes how to code the DatePickerDialog class and make changes to the ContactActivity to display and use the dialog.

The first task is to create a new class to hold the custom dialog code. Right-click com.example.mycontactlist in the src folder and select New > Class from the pop-up menu. Enter DatePickerDialog for the Name and click Finish. The new class opens with a limited amount of code. Replace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required