我想从基数 3 开始我的 seek baar 并增加 2,最大值为 9 如何设置,我需要 3、5、7、9、11。我的代码是
它没有按我的意愿工作,请帮忙
SeekBar sb1 = (SeekBar)findViewById(R.id.sBtaxitype);
sb1.setMax(11);
sb1.setLeft(3);
sb1.incrementProgressBy(2);
sb1.setProgress(0); // Set it to zero so it will start at the left-most edge
sb1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (progress < 3) {
progress = 3;
progress = progress + 2;
} else {
progress = progress + 2; // Add the minimum value (10)
}
TextView text = (TextView)findViewById(R.id.tvTaxitype);
text.setText(Integer.toString(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});