I've got a DialogFragment class implemented just like how google says in their Picker documentation.
https://developer.android.com/guide/topics/ui/controls/pickers
However the ability to set it to spinner mode as described here doesn't seem to work no matter what I do. Apparently the Material date picker doesn't support that anymore.. But I'm pretty sure DatePickerDialog instantiates the DatePicker shown below.. which says it supports spinner mode.
https://developer.android.com/reference/kotlin/android/widget/DatePicker
Here's my DialogFragment.. literally a copy from google And then I've tried referencing the datePicker object from the DialogFragment class..
class MyDatePickerDialog : DialogFragment(), DatePickerDialog.OnDateSetListener {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = DatePickerDialog( requireActivity(),this, year, month, day )
//
// I've tried these and they do nothing
//
dialog.datePicker.spinnerShown = true
dialog.datePicker.calendarViewShown = false
dialog.datePicker.datePickerMode = "spinner" <-- this isn't even valid
return( dialog )
}
override fun onDateSet(view: DatePicker?, year: Int, month: Int, dayOfMonth: Int) {
//Do something here
}
}
Then I've also tried setting these values through the theme styles.xml
<style name="DatePickerSpinner" parent="Theme.AppCompat.DayNight.Dialog">
<item name="android:datePickerMode">spinner</item>
<item name="android:calendarViewShown">false</item>
<item name="android:spinnerShown">true</item>
</style>
theme.xml
...
<item name="android:datePickerDialogTheme">@style/DatePickerSpinner</item>
...
And I verified the style was being used by the datepicker by changing some colors on it. I'm not sure what else is pertinent. Is this possible at all in 2021? Thanks.