gpt4 book ai didi

android - 如何以编程方式设置 datePickerMode ="spinner"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:49 25 4
gpt4 key购买 nike

我需要以编程方式创建 DatePicker。而且我不能使用 xml 布局。我知道在 xml 中设置微调器 datePickerMode="spinner" 然后我可以使用 datePicker.setSpinnersShown(true);datePicker.setCalendarViewShown(false) 我尝试将 AttributeSet 添加到构造函数中,但我不知道如何使用它。有人可以帮忙吗?如何在微调模式下创建 DataPicker?

谢谢

最佳答案

我已经找到一个帖子,它会描述你这个问题:

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

Android Material Design Inline Datepicker issue

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

We have to use an explicit XML attribute like this oneandroid: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 layoutfile using the requested attribute.

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

希望对你有帮助

关于android - 如何以编程方式设置 datePickerMode ="spinner"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34723495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com