Date Picker in Android using Kotlin:

Date picker:–

it is a widget in Android which is used to set date in application. For example in job sites they will provide option like how much time duration for availability for the job etc.

Steps to create a date picker in Android using kotlin:-

Step 1:- Add a  Date picker in your Layout(XML file).
Step 2:- Set all constraints for Date picker.
Step 3:- now go to mainactivity.kt  and apply a listener on datepicker like this :-

Jobdate(id of date picker).setondatechanged listener {datepicker,i,i2,i3->
Toast.maketext(this@mainActivity,text”Selected date:$i3/$i2/#i”Toast.length_long).(show)

Properties for modes of Date picker:–

like time picker date to kar also comes with two motors one is spinner mode and another is calender mode by default it is comes with calendar mode you can change it as your requirement. You can change it in your layout file(XML file):-

<Date picker
Android: datepicker mode=”spinner”

Finish

Leave a Reply

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