2

I have made use of seekbar for other requirements, now I have having trouble with a scale of this scope. I would like my max to be 350,000 (dollars) and my "min" or I should say "1" value to be 5,000. How would I implement this?

droidShot
  • 137
  • 2
  • 12

2 Answers2

1

If i understand correctly you want the seekbar to move by 5,000 up to 350,000.

350,000 / 5,000 = 70

    final TextView textView = findViewById(R.id.some_text);
    seekBar.setMax(69);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                seekBar.setProgress(progress);
                textView.setText(String.valueOf((progress+1)*5000));
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

Please tell me if I misunderstood :)

Simas
  • 43,548
  • 10
  • 88
  • 116
  • Any idea how I could implement a method that can quickly place the ',' in the right position? Really don't want to do a a bunch of comparing if statements. – droidShot Jul 14 '14 at 17:44
  • @droidShot `NumberFormat.getIntegerInstance().format(i);` as per [this answer](http://stackoverflow.com/a/7070368/3249477) – Simas Jul 14 '14 at 17:49
0
int min=5000;
int max=350000;

int value = (seekBar.getProgress()*(max-min))+min;
wiz
  • 321
  • 2
  • 4