joeli-wow / range-seek-bar

Automatically exported from code.google.com/p/range-seek-bar
0 stars 0 forks source link

Setting the Min And Max of RangSeeBar after onlistener is called #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am not too sure if this is already posted, but I had faced a problem. 
Suppose, I had range of 0-2, so when I moved the left seekbar 25%, it used to 
give min and max range as 0 and 2 but used to stay at 25% (which is confusing 
for the users, it should move to 1 (50%) or 0 ideally). So the below code sets 
the min and max value of seekbar once the seekbar is adjusted. And special 
thanks to the developer for providing the range seek bar. It is simply awesome.

final RangeSeekBar<Double> seekBar = new RangeSeekBar<Double>(0.0, 
iMatches*1.0, context);
        seekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Double>() {
            @Override
            public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Double minValue, Double maxValue) {
                // handle changed range values

                minValue = (double) Math.round(minValue);
                maxValue = (double) Math.round(maxValue);

                Log.i("Yoooo", "User selected new range values: MIN=" + minValue + ", MAX=" + maxValue);
                seekBar.setSelectedMinValue(minValue);
                seekBar.setSelectedMaxValue(maxValue);
            }
        });

Original issue reported on code.google.com by Mrudulpa...@gmail.com on 6 Sep 2013 at 10:33

GoogleCodeExporter commented 8 years ago
Your approach seems quite elegant to me :) Another approach has been posted 
already: https://code.google.com/p/range-seek-bar/issues/detail?id=1#c3

Original comment by tittel@kom.e-technik.tu-darmstadt.de on 6 Sep 2013 at 11:33

GoogleCodeExporter commented 8 years ago
Thanks for your feedback. I think the #1 is for increasing the steps..like if 
you want the seekbar to select only even or odd values or any particular steps, 
here I am adjusting the seekbar to set as the selected value so that it can 
look realistic. For a larger range it is fine, but if I am dealing with a small 
range (for eg 0-2), it seems pretty weird since there can be only three values 
(0,1,2) but the seekbar can be taken infinite values.

Original comment by Mrudulpa...@gmail.com on 6 Sep 2013 at 7:01