android - Horizontal ProgressBar: Toggling between determinate and indeterminate -


i'm trying toggle seekbar between the 2 modes display state of streaming media.

i've established correct graphics show when defining android:indeterminate tag in xml:

<seekbar     android:id="@+id/seekbar1"     android:indeterminate="false"     android:progressdrawable="@android:drawable/progress_horizontal"     android:indeterminatedrawable="@android:drawable/progress_indeterminate_horizontal"     android:indeterminatebehavior="cycle"     android:indeterminateonly="false"     android:progress="33"     android:secondaryprogress="66"     android:layout_height="wrap_content"     android:layout_width="match_parent"></seekbar> 

example

the trouble is, when trying switch calling setindeterminate(true), drawables don't appear change properly. in case of indeterminate->determinate, animation stops, , determinate->indeterminate, nothing happens.

what doing wrong?

the seekbar onsizechanged() initializes current selected background drawable, , called once when seekbar initialized. fix might be:

public class correctedseekbar extends seekbar {      public correctedseekbar(context context) {          super(context);     }      public correctedseekbar(context context, attributeset attrs) {          super(context, attrs);     }      public correctedseekbar(context context, attributeset attrs, int defstyle) {         super(context, attrs, defstyle);     }      protected void onsizechanged(int w, int h, int oldw, int oldh) {         boolean current = isindeterminate();         setindeterminate(!current);         super.onsizechanged(w, h, oldw, oldh);         setindeterminate(current);         super.onsizechanged(w, h, oldw, oldh);     }  } 

and in layout xml use <yourpackage.correctedseekbar ...

this doesnt nice, other workarounds might possible think main problem (bug?).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -