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 mProgr开发者_运维知识库essBar.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 ?
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)
精彩评论