【问题标题】:How to Customize seekbar with stepvalues如何使用 stepvalues 自定义搜索栏
【发布时间】:2014-01-18 05:40:13
【问题描述】:

我需要这样的搜索栏:

如果有人自定义了搜索栏,我不知道如何设置搜索栏的步长值,请帮助我

【问题讨论】:

标签: android xml android-layout seekbar


【解决方案1】:

我将提出三种方法。首先使用 comboSeekBar 来满足您的需要。

请参阅 thisthisLibrary link

secondly 您可以使用incrementProgressBythis Example 一样简单地更改Seekbar 中的步骤。或者你可以 setMax 为 7 。对于multiply the progress 的每一步,this Example 的每一步都是 10。

SeekBar seekBar = (SeekBar)layout.findViewById(R.id.seekbar);
seekBar.setProgress(0);
seekBar.incrementProgressBy(10);
seekBar.setMax(200);

【讨论】:

    【解决方案2】:

    你可以使用,

    seekBar.setProgress(0);  // change this to starting point... 
    seekBar.incrementProgressBy(10);
    seekBar.setMax(200); // change this to whereever you what to stop..
    

    在搜索栏下方显示一个文本视图

    既然你知道 incrementby 和 max 的值,你可以运行一个 for 循环.. 并且第一次获取 seek.getProgress() ,将它转换为字符串,然后继续将 incrementby 附加到 String....

    【讨论】:

    • 我需要在搜索栏下方设置步进值,就像在我的共享图像中一样 (10 20 30 40)
    • 是的,incrementProgressBy(10);会这样做..所以将 setmax(200) 更改为您的终点..
    • 对不起@Sunny 它没有在我的输出中显示步进值它显示像这样click here 但我需要clickhere
    猜你喜欢
    • 1970-01-01
    • 2019-12-01
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2015-11-16
    • 2014-06-19
    相关资源
    最近更新 更多