Reputation: 3817
I need to attach a progress bar to an AsyncTask. The AsyncTask works fine, but the progress bar is not.
The progress bar is actually a spinner! I imagine a progress bar being a horizontal thick line being filled from 0% to 100%. Instead I get a 'spinner'.
So, I tried mProgressBar.setIndeterminate(false); - it does not appear to have any effect. I guess the really important line is
style="?android:attr/progressBarStyleHorizontal" in the xml tag progressBar.
How can I do that from java code, and not xml ?
Upvotes: 2
Views: 2236
Reputation: 988
When creating the progressbar the third parameter is where you specify the attribute. Here is an example of using the StyleHorizontal
ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
Note: public ProgressBar (Context context, AttributeSet attrs, int defStyle)
Upvotes: 2