Search code examples
androidprogressseekbar

seekBar off by one driving me crazy


This seekBar is driving me nuts! Help me do this efficiently? I would like to have my starting value at 0 and max number displayed in textView $1,000,000. I would like to increment by $5,000. I also have tickers (plus and minus buttons) but they are off too because of my progress changed / textView display. it seems my textView is always 5,000 less than my actual progress. I can only get to 995,00 0 or do it differently and it skips from 10k to 0.

textView23 = (TextView) view.findViewById(R.id.textView23);
  seekBar1.setMax(199);
  seekBar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser)
            {

                {
                int newValue = seekBar.getProgress()* (5000);
                String nValue = NumberFormat.getInstance().format(newValue);
                textView23.setText("$" + nValue);
                }
                tempHouse = progress;
                Calculate();
            }
        }

Solution

  • Since 1000000 = 200 * 5000, it seems that seekbar.setMax(200)

    would be the correct value ;)