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.
PS I don't forget add ProgressBar to view which I set as dialog view.
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.
I know this is a late answer, but i found a solution my self.
To create a progressbar with a style resource, you can do it by creating a layout file for the progressbar that have already set the style.
progressbar_default.xml
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/ProgressDialogStyle.Default"/>
then you use the inflator from activity to create the progressbar.
mProgressBar =(ProgressBar) getLayoutInflater().inflate(R.layout.progessbar_default,null);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.