How to set run intervals in Range Seekbar

Hai I created a two-finger search bar using this example. But now I am facing a problem. Now I am getting the min and max value part. The next problem is setting the value for the slider in the search bar. How I want 500,1000,1500 .... etc, but according to the code example it evaluates progress 1,2,3..etc I provide the code for my main class.

source link: ' https://code.google.com/p/range-seek-bar/

   RangeSeekBar<Integer>seekBar = new RangeSeekBar<Integer>(1000, 1000000, context);

   seekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>() {

   @Override

  public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue,Integer maxValue) 

  {

  //handle changed range values

  Log.i("", "Price Range Values: MIN=" + minValue + ", MAX=" + maxValue);

  String range = "Price Range:" + minValue + "-" + maxValue;

  price_range.setText(range); 

      

+3


source to share


1 answer


I'm just developing a rental idea. So what you need to do is divide your Min- and Max-Range by 500 and right in yours onRangeSeekBarValuesChanged

by multiplying it by 500.

Code

    int startValue = 1000;
    int endValue = 100000;
    final int factor = 500;
    RangeSeekBar<Integer> seekBar = new RangeSeekBar<Integer>(startValue/factor, endValue/factor, this);
    seekBar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
            minValue = minValue*factor
            maxValue *= factor;
            value.setText(minValue + " : " + maxValue);
        }
    });

      



To make the user more transparent which range they have selected, you must also include notifyWhileDragging

. (This ensures that the method onRangeSeekBarValuesChanged

is called all the time while the user is dragging RangeSeekBar

).

seekBar.setNotifyWhileDragging(true);

      

+2


source







All Articles