【问题标题】:Android - dismiss progress bar automaticallyAndroid - 自动关闭进度条
【发布时间】:2013-02-13 13:14:51
【问题描述】:

当应用程序启动时,我从 ma​​in.xml 文件中填充了一个进度条,该进度条一直显示到列表为空。一旦列表中填充了来自 URL 的数据,我应该关闭这个进度条。 我如何在不使用进度对话框的情况下做到这一点?

我的 main.xml

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

    <ListView
        android:id="@+id/list_view_places"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:drawSelectorOnTop="false"
        android:fastScrollEnabled="true" >
    </ListView>

    <ProgressBar
        android:id="@+id/empty_progress_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />

</RelativeLayout>

【问题讨论】:

标签: android progress-bar


【解决方案1】:

尝试类似:

ProgressBar bar = (ProgressBar) findViewById(R.id.empty_progress_bar);
bar.setVisibility(View.GONE);

【讨论】:

  • 此解决方案有效。替代方法是 listview.setEmptyView(prog_bar);
【解决方案2】:

如果您将使用列表片段,则会自动处理进度条。一旦填充数据,它将自动关闭。

【讨论】:

    【解决方案3】:
    Try this :
    globalProgressDialog.dismissProgressDialog();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多