kovacs lorand
kovacs lorand

Reputation: 906

How to prevent the onProgressChanged event firing when setting the progress value of the seekbar from code?

If I set the progress or the max value of a seekbar from code then the onProgressChanged event gets fired. How to prevent this? I want the event to fire only when the user modifies the progress value from the UI by dragging the thumb of the seekbar.

Upvotes: 3

Views: 977

Answers (2)

Jrm
Jrm

Reputation: 83

Set your OnSeekBarChangeListener and check boolean fromUser

Upvotes: 4

Umesh Kumar Saraswat
Umesh Kumar Saraswat

Reputation: 768

When Every time you are setting the value from code every time onProgressChanged event fired. you can prevent it by giving the max value to seek bar into xml. and use a flag variable and put the code into that flag variable. e.g.

boolean flag = false;

onProgressChanged() {
    if(flag) {

---if you set the max bu code it skip the if body-------
    -------- do you code-----------------
    } 

    flag = true;
}

Upvotes: 0

Related Questions