android - 进度条 ICS

标签 android progress-bar android-4.0-ice-cream-sandwich

我有一项 Activity ,其中的 ListView 来自网络。 在加载数据时,我想显示一个进度对话框而不是 ListView 。

我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ProgressBar
        android:id="@+android:id/progress_large"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

    <ExpandableListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

我这样做是为了让进度条自行显示(这很有效):

setProgressBarVisibility(true);

但是,一旦 ListView 被填充(使用 AsyncTask),我希望进度条消失,但事实并非如此,它停留在 ListView 之上。

这是我在 AsyncTask 中所做的:

 @Override
    protected void onPostExecute(Void result) {
        setProgressBarVisibility(false);

        //... and some code to update UI
    }

最佳答案

在你的代码中这样做,

@Override
    protected void onPostExecute(Void result) {
         //progressBar.dismiss(); //this dismisses the progressbar
              progressBar.setVisibility(ProgressBar.GONE)

        //... and some code to update UI
    }

关于android - 进度条 ICS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12292038/

相关文章:

android - 在更高版本的 Android 上对幼儿安全的应用程序

安卓 : ListView get jumbled up while trying to write ViewHolder class for ListView with Section Headers

.net - 垂直进度条模板.net

c# - 带有进度条 WPF 的异步 Google 文件上传

c# - Windows窗体应用程序中的进度栏​​异常

android - ImageButton 的触摸反馈 (Android)

android - setColorFilter() 在 Android 4 上损坏,在 Android 5 上工作

android - 如何在用户单击按钮时运行已安装的应用程序

java - 将 OpenCv DCT 转换为 Android

java - 如何让Android Studio中的actionbar消失?