我想创建搜索栏,我想增加这样的搜索栏
minvalue = 5,maxvalue = 10
寻求条形值增量:0 1 2 3 4 5 6
我想要搜索这样的条形值:5.10,5.20,5.30 ...... 9.90,10
如何实现这一目标。?
答案 0 :(得分:2)
aSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
float value = ((float)progress / 20.0);
String yourprogress = String.valueOf(value+5.0f);
// yourprogress is your desiger output
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
答案 1 :(得分:1)
aSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
float value = ((float)progress / 20.0);
String progress = String.valueOf(value+5.0f);
// value now holds the decimal value between 0.0 and 10.0 of the progress
// Example:
// If the progress changed to 45, value would now hold 4.5
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
答案 2 :(得分:0)
这对浮动来说是不可能的。 您必须通过乘以增量来制定解决方法。
看到这个回复: duplicate