2014-03-06 14 views
6

Ich habe progressdialog in asynctask dynamisch erstellt. Ich verwende einen benutzerdefinierten Stil für meine App. Als ich das tat, änderte sich mein progressdialog Stil zu weißer Farbe. Ich brauche meinen Standardstil in Schwarz mit weißem Text.Benutzerdefinierte progressdialog in Android dynamisch erstellt

Meine Java-Datei:

class LoginTask extends AsyncTask<Void, Void, Void> { 

private final ProgressDialog dialog = new ProgressDialog(Login.this); 

@Override 
protected void onPreExecute() { 
    this.dialog.setMessage("Logging in..."); 
    this.dialog.show(); 
} 

// my prog 

@Override 
    protected void onPostExecute(Void result) { 
     if (this.dialog.isShowing()) { 
     this.dialog.dismiss(); 
     }} 

Mein style.xml:

<style name="AppBaseTheme" parent="android:Theme.Light"> 

</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="AppBaseTheme"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
    <item name="android:windowBackground">@drawable/blue</item> 
    <item name="android:textColor">@color/white</item> 
    <item name="android:editTextColor">@color/white</item> 
    <item name="android:buttonStyle">@android:style/Widget.Holo.Button</item> 
    <item name="android:dropDownSpinnerStyle">@android:style/Widget.Holo.Spinner</item> 
    <item name="android:textAppearanceButton">@android:style/TextAppearance.Widget.Button</item> 
    <item name="android:progressBarStyle">@style/ProgressBar</item> 

</style> 
<style name="ProgressBar" parent="@style/android:Theme.Holo"> 
    <item name="android:textColor">@color/red</item> 
    <item name="android:background">@color/green</item> 
</style> 

+1

dann eine andere 'Theme' für Ihre' Fortschritt Dialog' erstellen und wie 'ProgressDialog pd = new ProgressDialog (activity.This, R.style.MyTheme);' –

+0

Warum diese Zeile nicht funktioniert @ Android: style/Widget.ProgressBar Yashwanth

Antwort

10

Ändern Sie die unterhalb der Linie der style durch Ihren Konstruktor übergeben ...

private final ProgressDialog dialog = new ProgressDialog(Login.this); 

zu th ist ...

private final ProgressDialog dialog = new ProgressDialog(Login.this, R.style.ProgressBar); 

Update:

ich ändern Sie einfach den style wie unten ... und seine Arbeit für.

<style name="ProgressBar" parent="@style/android:Theme.Holo"> 
    <item name="android:textColor">#FFFFFF</item> 
    <item name="android:background">#000000</item> 
</style> 
+0

direkt auf dem Weg Hamid! –

+0

Ich brauche Standardthema schwarz Backgroung und Text in weiß. mit dieser Linie. @ android: style/Widget.ProgressBar Yashwanth

+0

Jetzt, welche Farbe bekommen Sie? –