BadCash BadCash - 1 month ago 5
Android Question

Android: SeekBar onProgressChanged-event doesn't get fired when setting progress programmatically

My onProgressChanged()-event doesn't get fired when I set the progress of a SeekBar programmatically, but it does get fired perfectly fine when I physically move the SeekBar slider.

I'd expect the event to fire when using setProgress() - the Android Developer Reference even states that:

public abstract void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser)

Notification that the progress level has changed. Clients can use the fromUser parameter to distinguish user-initiated changes from those that occurred programmatically.

Some code snippets from my project:

protected void onCreate(Bundle savedInstanceState) {

final SeekBar mySeekBar = ((SeekBar) findViewById(;

mySeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
// Do some stuff

protected void onResume() {

final SeekBar mySeekBar = ((SeekBar) findViewById(;
mySeekBar.setProgress(someValue); // This SHOULD trigger onProgressChanged(), but it doesn't...


+1 for Romuald Brunet's answer:

Here was my "hack" to fix it:

        <SeekBar android:id="@+id/seekbar" 
            android:max="200" />

Note the progress="1", set the default progress in the layout to 1, then in my code when I actually default it to 0, a change in the progress occurs and the onProgressChanged() event fires.