Getting Choosy with Dates and Times

What would your Task Reminder application be without a way to set the date and time for the reminder? Well, it wouldn't be a Task Reminder application at all! It would simply be a Task List application — and that's kind of boring if you ask me.

If you've done any programming with dates and times in other programming languages, you know that building a mechanism for a user to enter a date and a time can be a painstaking process all in itself. However, I'm happy to report that the Android platform has relieved Android programmers of this difficulty. The Android platform provides two classes that assist you in this process — the DatePicker and TimePicker — and these pickers also provide built-in classes that allow you to pop up a dialog box so that the user can select a date and a time. This means you have the option to either embed the DatePicker or TimePicker into your application's views or to use the Dialog classes, which saves you the process of creating a view in which to contain the DatePicker and TimePicker views.

Enough jibber-jabber about what the picker widgets can do. I'm sure you're ready to start using them!

Creating picker buttons

You have not added the DatePicker or TimePicker to the Task Reminder application yet, but you do so in this section. Part of the reminder_edit.xml file contains mechanisms to help display the DatePicker and TimePicker. These mechanisms are located after the EditText definitions discussed earlier in this ...

Get Android™ Tablet Application Development For Dummies® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.