I managed to find a solution without the need to use other projects or starting from scratch. It is probably not the BEST solution, but it seems to work perfectly fine for me.
I used the DatePicker
widget rather than a calendar as it is simpler and does exactly what I need. I essentially remove (View.GONE
) the date picker until one of the buttons is selected (e.g. "select full date", "select month in year", "select year").
In the first case with the "select full date", I just set the date picker to VISIBLE
. That is all that is required.
In the second case with "select month in a year", I set the date picker VISIBLE
but I also call a method which using Reflection to hide the DAY part of the date picker.
The final case is like above, except I hide the DAY
and MONTH
part of the date picker.
In all the cases, a new button appears below the date picker "Set Date" or "Set Month" or "Set Year" (depending on which initial button was selected). Each of the buttons will extract the relevant field information from the date picker.