0

I've installed my .apk on Transformer Prime 201 with android ver. 4.0.3 but ProgressDialog does't look like custom ProgressDialog on device.

Why is it so? What does I must to change in my code for using custom ProgressDialog style on the device?

ProgressDialog progressDialog = new ProgressDialog(this.context);
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMessage(MESSAGE);
progressDialog.show();

enter image description here enter image description here

Sviatoslav
  • 1,301
  • 2
  • 17
  • 42

3 Answers3

5

The accepted answer above will work, but its approach is like taking a sledgehammer to crack a peanut. You'll crack the nut, but you may also damage the table below the nut. It doesn't make sense to change the entire app's theme just to change the look of one progress dialog.

imo a better solution is to keep your app's theme unchanged and just change the theme of the progress dialog. You can get the Gingerbread progress dialog look on all Android versions with the following code.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
    dialog = new ProgressDialog(yourActivity, AlertDialog.THEME_TRADITIONAL);
else
    dialog = new ProgressDialog(yourActivity);
ServerCode
  • 151
  • 2
  • 5
4

You need to set your App to the Holo Theme. This progressIndicator is only shown if you use the Holo theme in your App.

The problem is that you can not simply set the Theme because devices with Android Versions smaller then 3 don't have this theme available.

Therefor you neet to create two Theme files. One in the folder res/values/ and one in the folder res/values-v11/ The file in the folder res/values-v11 will be loaded for all devices with API level 11 or greater.

In the values-v11 folder define a theme for your app like this:

<resources>
   <style name="Theme" parent="@android:style/Theme.Holo.Light"></style>
</resources>

In the default values folder define a theme like this:

<resources>
   <style name="Theme" parent="@android:style/Theme.Light.NoTitleBar"></style>
</resources>

Now apply this theme to your application in the Manifest:

<application
    android:name=".name.App"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme" >

For more informations on this read the documentation on themes and styles.

Janusz
  • 187,060
  • 113
  • 301
  • 369
  • Hi, i have the same problem. I set in the Manifest all activities to Holo.Dark.NoActionBar but the Dialog appears "old-style"... – Emaborsa Jul 18 '13 at 13:49
0
ProgressDialog progressDialog;

if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB){
   progressDialog = new ProgressDialog(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Light_Dialog));
}else{
   progressDialog = new ProgressDialog(context);
}

progressDialog.setMessage("Loading....");
progressDialog.show();
JeffMeJones
  • 354
  • 4
  • 5