首先在Android日历视图中显示年份选择 [英] Show year selection first in Android Calendar View

查看:363
本文介绍了首先在Android日历视图中显示年份选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

棒棒糖之后,DatePicker具有非常漂亮的calenderview选择日期。但是问题是选择年份。大多数普通人在选择年份时遇到麻烦。他们只是滚动。滚动更改年份需要很长时间。因此,我需要在android中打开Datepicker对话框时首先显示年份选择。

After Lollipop, DatePicker having a very beautiful calenderview to select the date. But the issue is selecting year. Most of the common people facing trouble to selecting year. They just scrolling. It take too long time to scroll for changing years. So I need to show year selection first when open Datepicker Dialog in android.

Datepicker通常以如下方式打开:

The Datepicker normally opening like below one:

但这应该从年份选择开始。如下所示:

But it should be start from year selection. like below one:

推荐答案

您可以获取对年视图的引用,然后只需模拟用户单击即可将其打开。

You can get a reference to year view and then just simulate user click to open it.

dataPicker.getTouchables().get( 0 ).performClick();

更新:
如果不清楚,我将解释每个步骤。您首先需要引用datePicker。使用datePicker引用,可以使用getTouchables()方法获取datePicker组件。
组件年份位于首位,因此需要调用.get(0)以获取年份的引用。
之后,只需模拟用户单击即可在开始时打开年视图,而不是等待用户单击它。

UPDATE: If not clear I will explain every step. You need to have datePicker reference first. With datePicker reference you can get datePicker components with getTouchables() method. Component year is at the first place so need to call .get(0) to get a reference to year. And after that just simulate user click to open years view at the start rather than waiting user to click on it.

这篇关于首先在Android日历视图中显示年份选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆