18

Working with Android DatePicker is such a pain in the ass.

You want to have your DatePicker appearing as a SpinnerView? Well, easy!

If you're under API 21, you can use the following method 'setSpinnerViewShown()'. If you're between API 21 and API 23 you need to add some style configuration. And if you're above of API 23 you can't use both of the methods above, you need to create a custom xml with the attribute "datePickerMode" (no, datePickerMode can't be set programmatically, it would be too easy to guess).

If you want to add a listener to it, you think it might be a method called 'setDateChangeListener' or something like this? Well no! You must use the 'init(year, month, day, Listener)' method, logic!

If you think you're finished with this bullshit, of course not. Their is a known bug on API 21 that you must take into account (but this bug isn't fixed, no, it's just documented somewhere on google forums).

I don't know the team that designed the DatePicker for Android, but it might a team of champanzee that randomly changed their minds to the phases of the moon!

Comments
  • 5
    Yes it is retarded as hell. I just recommend not to use the native code, but to use 3rd party libs.

    Search like material date picker in google or github.
  • 2
    Try betterpickers samples app in play store. Their lib looks great.
  • 1
    Thanks but at this time I already take too much time to make this working that I won't touch it soon. But I keep it in mind for the next project !
Add Comment