-1

Sorry about what is likely a noob question. I am working on a simple android app that involves a seekbar.

The app runs, however, when I release the seekBar it causes my app to crash.

Im trying to set a textview when the seekbar is released, but instead of setting the textview, the app crashes.

I believe this is my issue. When I comment it out, I can drag the seekbar with no issues.

progressTextView.setText(progressChangedValue) ;

XML CODE

<SeekBar
    android:id="@+id/seekBar"
    android:layout_width="329dp"
    android:layout_height="32dp"
    android:layout_marginStart="29dp"
    android:layout_marginLeft="29dp"
    android:layout_marginEnd="26dp"
    android:layout_marginRight="26dp"
    android:layout_marginBottom="52dp"
    android:max="1000"
    android:progress="500" />

JAVA

SeekBar seeker = (SeekBar) findViewById(R.id.seekBar) ;
        progressTextView = (TextView)findViewById(R.id.seekBarLabel);




            seeker.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                int progressChangedValue = 0;
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                progressChangedValue = progress;
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                progressTextView.setText(progressChangedValue) ;
                }
            });
ayellowbusman
  • 47
  • 1
  • 8

1 Answers1

1

You're passing an integer to setText(int), which is a resource id and does not exist in your case, so try changing it to a String or other types instead:

progressTextView.setText(String.valueOf(progressChangedValue));
Aaron
  • 3,764
  • 2
  • 8
  • 25
  • Thanks! That took care of it. Makes sense. The stack trace was giving me this: "Invalid ID 0x00000200." and then a bunch of other stuff. – ayellowbusman Nov 15 '18 at 02:09