【问题标题】:infinite progressbar in androidandroid中的无限进度条
【发布时间】:2013-11-14 06:27:24
【问题描述】:

我想在 android 的 Progress 对话框中设置大字体的消息。

我正在使用以下代码,

 progress_dialog=new ProgressDialog(this);

 progress_dialog.show(About_Us_Activity.this, Html.fromHtml(""), Html.fromHtml("big>Message...</big>"), false);

我在 AsyncTask 的 onPreExecute() 方法中使用了上面的代码,并在 onPostExecute 方法中关闭,问题是我的进度对话框无限运行,这意味着它没有关闭。我的代码有什么问题。 log cat 没有显示错误。

【问题讨论】:

  • 您是否关闭了 onPostExecute 中的对话框?
  • 你确定 onPostExecute 会被调用吗?
  • 是的@prateek,请阅读整个问题,我已经提到我已经关闭了进度对话框。
  • 您能否确认您的 onPostExecute 已执行,如果是,请在 onPostExecute 中分享您的解雇部分,这将有助于跟踪问题。
  • 我使用此代码关闭 onPostExecute 上的对话框 if(progressdialog.isShowing()) { progressdialog.dismiss(); }

标签: android progressdialog


【解决方案1】:

1.使用自定义对话框progress.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal" >
 <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+android:id/progress_large"
        android:layout_marginBottom="28dp"
        android:layout_marginLeft="21dp"
        android:layout_toRightOf="@+android:id/progress_large"
        android:text="Loading.."
        android:textSize="15dp"
        android:textStyle="bold" />
   <ProgressBar
        android:id="@+android:id/progress_large"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />
</RelativeLayout>

2.调用java文件中的progress.xml: setContentView(R.layout.progress);

3.在AndroidManifest.xml中,内部标签使用android:theme="@android:style/Theme.Holo.Dialog"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 2019-03-26
    • 2016-02-20
    • 1970-01-01
    • 2015-01-24
    相关资源
    最近更新 更多