I have tried seekbar normal task to display the time from 1 to 12 but I have little different requirement.
请有人可以帮助我获得像这样的搜索栏显示值。
您的搜索栏的范围是从最小到最大。您必须定义您需要的范围。例如,您想要使用搜索栏选择从 0:00 到 23:59 的日期,步长为 15 分钟。因此,您需要 min = 0 且 max = 24 * 4 的范围栏。
当您的搜索栏更改时,您需要计算实际选择的时间。为此,您可以获取 SeekBar 进度并将其乘以 15 分钟。您将获得选定的分钟数。
示例代码:
seekBar.setMax(24 * 4); //24 hours and 4 step in one hour.
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangetListener() {
public void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser) {
int hours = progress / 4; // it will return hours.
int minutes = (progress % 4) * 15; // here will be minutes.
}
});
希望这可以帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)