Android - 自动关闭进度条

时间:2013-02-13 13:14:51

标签: android progress-bar

启动应用程序时,我会从 main.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>

3 个答案:

答案 0 :(得分:9)

尝试类似:

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

答案 1 :(得分:3)

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

答案 2 :(得分:0)

Try this :
globalProgressDialog.dismissProgressDialog();
相关问题