Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set style to a progressBar programmatically on Android

I have ProgressBar style in style.xml. When I create layout, put there ProgressBar and set style like:

style="@style/ProgressBarStyle"

set layout to dialog and all is fine.

Other way create view for dialog programmatically. So for ProgressBar I have next code:

new ProgressBar(context, null, R.style.ProgressBarStyle);

But in this way there is nothing instead ProgressBar.

P.S. I don't forget add ProgressBar to view which I set as dialog view.

like image 790
McBodik Avatar asked Oct 10 '14 16:10

McBodik


1 Answers

You can set your style from the constructor, for instance:

progressBar = new ProgressBar(activity, null, android.R.attr.progressBarStyleSmall);

Where the third attribute is the style.

In your case, I think the error is to choose a wrong one. Just this.

like image 122
Juan Aguilar Guisado Avatar answered Oct 03 '22 09:10

Juan Aguilar Guisado