-1

Hai i created a two thumb range seek bar using given code.its working fine.now i want to set the specific range for the slider in seekbar like, factor =100 upto 30000, after that factor should be 500..means from 1000 t0 30000 progress interval 100 and after 30000 progress interval shouldbe 500 how can i do that..i am refering this example

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

orginal code :

int startValue = 1000;
int endValue = 200000;
final int factor = 500;
String range_min_value ="0",range_max_value ="200000"

    final RangeSeekBar_two<Integer> seekBar = new RangeSeekBar_two<Integer>(startValue/factor, endValue/factor, this);
        seekBar.setOnRangeSeekBarChangeListener(new RangeSeekBar_two.OnRangeSeekBarChangeListener<Integer>() {
            @Override
            public void onRangeSeekBarValuesChanged(RangeSeekBar_two<?> bar, Integer minValue, Integer maxValue) {
                minValue = minValue*factor;
                maxValue *= factor;

                seekBar.setNotifyWhileDragging(true); 
                 range_min_value = ""+minValue;
                 range_max_value = ""+maxValue;
                 value_range.setText(minValue+" - "+maxValue); 

            }
        });

Updated code:

int startValue = 1000;
int endValue = 200000;
final int factor = 500;
String range_min_value ="0",range_max_value ="200000"

        final RangeSeekBar_two<Integer> seekBar1 = new RangeSeekBar_two<Integer>(startValue/factor, endValue/factor, this);
        seekBar1.setOnRangeSeekBarChangeListener(new RangeSeekBar_two.OnRangeSeekBarChangeListener<Integer>() {
            @Override
            public void onRangeSeekBarValuesChanged(RangeSeekBar_two<?> bar, Integer minValue, Integer maxValue) {

                seekBar1.setNotifyWhileDragging(true); 
                 range_min_value = ""+minValue;
                 range_max_value = ""+maxValue;

                 if (minValue < 30000) {
                        factor = 100;
                        minValue = minValue * factor;
                        maxValue *= factor;
                        value_range.setText(minValue+" - "+maxValue); 
                    } else {
                        factor = 500;
                        minValue = minValue * factor;
                        maxValue *= factor;
                        value_range.setText(minValue+" - "+maxValue); 
                    }


            }
        });
learner
  • 331
  • 1
  • 9
  • 22

1 Answers1

0

If I understand your question correctly here is what you need

if (minValue < 10000) {
    factor = 100;
    minValue = minValue * factor;
    maxValue *= factor;
    value.setText(minValue + " : " + maxValue);
} else {
    factor = 500;
    minValue = minValue * factor;
    maxValue *= factor;
    value.setText(minValue + " : " + maxValue);
}

If you want something else please inform me. Hope it helps.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
Syeda Zunaira
  • 5,191
  • 3
  • 38
  • 70
  • you can use it in your onRangeSeekBarValuesChanged method. – Syeda Zunaira Nov 26 '14 at 10:53
  • Zoain i added updated code..but still am not getting output vat i am expecting..it incrimenting 100 from start to end..pls check the code – learner Nov 27 '14 at 06:27
  • Please debug your code and check that what is the initial value of minValue and does it ever exceeds from 10000. – Syeda Zunaira Nov 27 '14 at 06:47
  • check the incremental increase in minValue and tell me what happpened when minValue exceeds from 10000? – Syeda Zunaira Nov 27 '14 at 06:49
  • When you need an increment of 500? I mean when which value becomes equal to 10000? – Syeda Zunaira Nov 27 '14 at 06:50
  • i am new this..so am bit confused...when i remove int factor=500; in my code it showing error factor cannot be resolved to a variable..then i added just int factor as variable.removed 500..but it crashing my app.. – learner Nov 27 '14 at 06:57
  • no you should not remove that. Did you debug the code and check the value of minValue in each step? – Syeda Zunaira Nov 27 '14 at 07:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65741/discussion-between-zoain-and-learner). – Syeda Zunaira Nov 27 '14 at 07:02