android date pickerAndroid Date Picker :

Another view that’s the same as the TimePicker is the DatePicker. using the DatePicker, you can enable users to select a specific date on the activity. This example shows you how to use the DatePicker.

Solution Stuff :

In this Android DatePicker example, you can use “android.widget.DatePicker” class to render a DatePicker.

You just need to drag and drop Date Picker widget in Android UI (according below figure) and write some code for Datepicker application in java class and xml file:

Note : This example (Project) is developed in Eclipse Version Kepler, tested on Android 4.4.2 (KitKat Version) and SDK build-tools 22.6.3

Android Date picker example

Complete Source code :

1. Put this code in main_activity.xml

The following code snippet in your activity_main.xml file, which contains a Button and a DatePicker view:

2. Put this java code in MainActivity.class

Like the TimePicker, you call the getMonth(), getDayOfMonth(), and getYear() methods of the DatePicker to get the chosen month, day, and year, respectively. Figure shows the DatePicker in action.

android date picker example

Android DatePicker Example Source code Download :


Leave a Reply