In this video, I show how to add a calendar widget to an Android fragment, without taking up too much space. I create a button that invokes a DateDialog.
This requires several steps:
1) Add a button to an exitsting constraint layout,
2) create a class, DatePickerFragment, that extends DialogFragment,
3) Return a new DatePickerDialog from the onCreateDialog function,
4) create an onClickListener for the button we added,
5) Instantiate the DatePickerFragment from the button click event handler, and then invoke show(),
6) Create an interface for a callback that will receive the date that the user selected,
7) Add the callback interface to our Fragment (or Activity) class,
8) Format the date with a SimpleDateFormatter,
9) Update the button text to show the date, and
10) show all of this in the debugger.
This video is part of a playlist, available at: • Learning Module 2 3048 Q
All source code is freely available on GitHub, at: https://github.com/discospiff/MyPlant...