Hai我使用给定的代码创建了一个两个拇指范围搜索栏。工作正常。现在我想在搜索栏中设置滑块的特定范围,因子= 100到30000,之后该因子应为500..means从1000 t0 30000进度间隔100和30000进度间隔应该是500我怎么能这样做..我正在参考这个例子
源代码:https://code.google.com/p/range-seek-bar/
原始代码:
int startValue = 1000;
int endValue = 200000;
final int factor = 500;
String range_min_value ="0",range_max_value ="200000"
final RangeSeekBar_two<Integer> seekBar = new RangeSeekBar_two<Integer>(startValue/factor, endValue/factor, this);
seekBar.setOnRangeSeekBarChangeListener(new RangeSeekBar_two.OnRangeSeekBarChangeListener<Integer>() {
@Override
public void onRangeSeekBarValuesChanged(RangeSeekBar_two<?> bar, Integer minValue, Integer maxValue) {
minValue = minValue*factor;
maxValue *= factor;
seekBar.setNotifyWhileDragging(true);
range_min_value = ""+minValue;
range_max_value = ""+maxValue;
value_range.setText(minValue+" - "+maxValue);
}
});
更新的代码:
int startValue = 1000;
int endValue = 200000;
final int factor = 500;
String range_min_value ="0",range_max_value ="200000"
final RangeSeekBar_two<Integer> seekBar1 = new RangeSeekBar_two<Integer>(startValue/factor, endValue/factor, this);
seekBar1.setOnRangeSeekBarChangeListener(new RangeSeekBar_two.OnRangeSeekBarChangeListener<Integer>() {
@Override
public void onRangeSeekBarValuesChanged(RangeSeekBar_two<?> bar, Integer minValue, Integer maxValue) {
seekBar1.setNotifyWhileDragging(true);
range_min_value = ""+minValue;
range_max_value = ""+maxValue;
if (minValue < 30000) {
factor = 100;
minValue = minValue * factor;
maxValue *= factor;
value_range.setText(minValue+" - "+maxValue);
} else {
factor = 500;
minValue = minValue * factor;
maxValue *= factor;
value_range.setText(minValue+" - "+maxValue);
}
}
});
答案 0 :(得分:0)
如果我理解你的问题,这就是你需要的
if (minValue < 10000) {
factor = 100;
minValue = minValue * factor;
maxValue *= factor;
value.setText(minValue + " : " + maxValue);
} else {
factor = 500;
minValue = minValue * factor;
maxValue *= factor;
value.setText(minValue + " : " + maxValue);
}
如果你想要别的东西请告诉我。 希望它有所帮助。