Custom progressdialog in android created dynamically

别来无恙 提交于 2020-01-01 09:22:01

问题


I've created progressdialog in asynctask dynamically. I use custom style for my app. when I did that my progressdialog style changed to white color i need my default style in black with white text.

My java file:

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();
        }}

My 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:


Change the below line to pass the style through your constructor...

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

to this...

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

Update:

I just change the style as below...and its working for.

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


来源:https://stackoverflow.com/questions/22217673/custom-progressdialog-in-android-created-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!