Read More
Read now

how we can use DatePickerDialog in android

Save

In this blog we will read how we can use DatePickerDialog in android . DatePikcerDialog in android allows user to select date . DatePickerDialog allows user to select day,month and year in our application.

activity_main.xml

In xml file we will use a button and a Textview . when user click on button he will see a Dialog and he can select date from that dialog. Which date user select will be visible in text view and you can see complete code for activity_main.

DatePickerDialog select date from instance of Calendar so we use get Instance method. check below code and  See how can we get instance of Calendar.

If you want to set  date so use  OnDateSetListener() interface .check and see below to set date from date picker dialog.

Initialize date picker dialog and send needed parameter .

 

MainActivity

In MainActivity you can we use a click listener when you click on button it will show a dialog and here you can select date.

You can change background color and button colors. In style you can provide negative button and positive button .

styles.xml

And here you can check screenshot of date Picker how it will show

DatePickerDialog

So here we discussed about how we can use DatePickerDialog in android  .  Thanks for reading this blog and You can get other blogs from here

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home