How to set datePickerMode=“spinner” programmatically?

前端 未结 2 2211
醉酒成梦
醉酒成梦 2021-02-20 00:47

I need create DatePicker programmatically. And i can\'t use xml layout. i know set spinner in xml datePickerMode=\"spinner\" and then i can use datePicker.set

2条回答
  •  余生分开走
    2021-02-20 01:15

    I've already found a post, which it would describe you this problem:

    I have found a the explanation in the following post (which describes a problem very similar to mine) :

    Android Material Design Inline Datepicker issue

    In fact the setCalendarViewShown(false) and setSpinnersShown(true) are apparently not working anymore in latest versions.

    We have to use an explicit XML attribute like this one android:datePickerMode="spinner".

    The problem is that I'm using a DialogFragment without any XML layout (just a date picker dialog). So I cannot set any XML attribute.

    The solution is to create a dedicated custom dialog with an XML layout file using the requested attribute.

    FROM: Impossible to make my DatePickerDialog use a spinner style programmatically

    Hope it help

提交回复
热议问题