Time for action - listening to the SeekBar

The user interface is now populated with the default data. However, it's not interactive at all. If you drag the SeekBar the How Many People: label will remain at its default value of 2. We need an event listener to update the label when the SeekBar is used.

  1. Open the ReviewActivity Java source in your editor or IDE.
  2. Add SeekBar.OnSeekBarChangeListener to the interfaces that ReviewActivity implements.
  3. In onCreate, after fetching the SeekBar with findViewById, set its OnSeekBarChangeListener to this:
    SeekBar people = (SeekBar)findViewById(R.id.people); people.setOnSeekBarChangeListener(this);
  4. Implement the onProgressChanged method to update peopleLabel:
    public void onProgressChanged( SeekBar bar, int progress, ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.