Android中的自定义进度对话框是动态创建的 [英] Custom progressdialog in android created dynamically

查看:94
本文介绍了Android中的自定义进度对话框是动态创建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在asynctask中动态创建了progressdialog.我为我的应用程序使用自定义样式.当我将ProgressDialog样式更改为白色时,我需要使用默认的黑色和白色文本样式.

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.

我的java文件:

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

我的style.xml:

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>

推荐答案

更改下面的行以将style通过您的构造函数...

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

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

对此...

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

更新:

我只是将style更改如下,并对其起作用.

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>

这篇关于Android中的自定义进度对话框是动态创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆