My idea is to use AlertDialog and set the DatePicker for it.
My code is:
AlertDialog.Builder builder = new AlertDialog.Builder(this); DatePicker picker = new DatePicker(this); picker.setCalendarViewShown(false); builder.setTitle("Create Year"); builder.setView(picker); builder.setNegativeButton("Cancel", null); builder.setPositiveButton("Set", null); builder.show();
it works, but my question is: how can I have listeners on the set and cancel button ?
About the set button, I would like the listener and (of course) get the user's date (his date choice)
I also want to show only the year , so I want to hide the data of the day and month.
source share