【问题标题】:Custom progressdialog in android created dynamicallyandroid中的自定义进度对话框动态创建
【发布时间】:2014-04-08 16:29:00
【问题描述】:

我在 asynctask 中动态创建了进度对话框。我为我的应用程序使用自定义样式。当我这样做时,我的进度对话框样式更改为白色,我需要我的默认样式为黑色和白色文本。

我的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:

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

【问题讨论】:

  • 然后为您的Progress Dialog 创建另一个Theme 并设置为ProgressDialog pd = new ProgressDialog(Activity.this, R.style.MyTheme);
  • 为什么这条线不起作用@android:style/Widget.ProgressBar

标签: android progressdialog android-progressbar


【解决方案1】:

更改以下行以通过您的构造函数传递style...

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

到这个...

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

更新:

我只是将style 更改为如下...以及它的工作原理。

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

【讨论】:

  • 我需要默认主题黑色背景和白色文本。用这条线。 @android:style/Widget.ProgressBar
  • 现在,你要的是哪种颜色?
  • 白色背景和文字。
  • 它正确地为我工作......**白色文本和黑色背景**。清理您的项目,然后再次运行。
  • 是的,这种方式工作正常,但我不能用这种方式 @android:style/Widget.Holo.ProgressBar
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-24
  • 2012-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多