Question: I've this Seekbar and an int defined outside the seekbar. The value of the int is the seekbar progress. All is fine, except that I want the value of the int to change as the progress of the seekbar changes. Right now, it gets the value from the seekbar only when the program is launched.

```
    int tableNumber = seekBar.getProgress();
    SeekBar seekBar = findViewById(R.id.seekBar);

    seekBar.setMin(1);
    seekBar.setMax(20);
    seekBar.setProgress(10);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            Log.i("Number", Integer.toString(i));

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

```

Answer: 
You have to update the `tableNumber` variable every time the seekbar progress changes.

```
    public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
        Log.i("Number", Integer.toString(i));
        tableNumber = i; // add this line 
    }

```
declare `tableNumber` outside method and set its value in `onProgressChanged`

```
int tableNumber = 0; // declare above method

public void someInitiatingMethodMaybeOnCreate(){
    SeekBar seekBar = findViewById(R.id.seekBar);
    tableNumber = seekBar.getProgress(); // initial set

    seekBar.setMin(1);
    seekBar.setMax(20);
    seekBar.setProgress(10);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            Log.i("Number", Integer.toString(i));
            tableNumber = i; // set current progress
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

```