Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Jul 29, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link
Contributor

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 [email protected] on 6 Sep 2013 at 10:33

@GoogleCodeExporter
Copy link
Contributor Author

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 [email protected] on 6 Sep 2013 at 11:33

@GoogleCodeExporter
Copy link
Contributor Author

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 [email protected] on 6 Sep 2013 at 7:01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant