如何更改了Android TimePicker分钟间隔? [英] How do i change the Android TimePicker minute intervals?
问题描述
我写这封信,用户需要指定在某一时间点的应用程序,但我似乎无法弄清楚如何设置分钟值,用户可以从中选择,以5只使用增量,而不是增量为1。
I am writing an application where the user needs to specify a given point in time, but i can't seem to figure out how to set the minute values that the user can choose from, to only use increments of 5 instead of increments of 1.
简单地说,当通过提供大量的用户滚动,他/她必须只看到0,5,10,15等。
Simply put, when the user scrolls through the available amounts, he/she must only see 0,5,10,15 etc.
感谢你在前进。
推荐答案
所有相关答案需要你设置一个OnTimeChangedListener。 我的分辨率是您扩展了Android的TimePicker,并修改它的构造器:
all relative answer need you to set an OnTimeChangedListener. My resolution is that you extends android TimePicker,and modify the constructor of it:
// minute
mMinuteSpinner = (NumberPicker) findViewById(R.id.minute);
mMinuteSpinner.setMinValue(0);
mMinuteSpinner.setMaxValue(3);
mMinuteSpinner.setDisplayedValues(new String[]{"0", "15", "30", "45"});
mMinuteSpinner.setOnLongPressUpdateInterval(100);
mMinuteSpinner.setFormatter(NumberPicker.getTwoDigitFormatter());
这样你就可以得到你想要的间隔时间。
so you can have the interval you want.
这篇关于如何更改了Android TimePicker分钟间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!