Android - 自动关闭进度条

sur*_*udi 1 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>
Run Code Online (Sandbox Code Playgroud)

Rag*_*ood 9

尝试类似的东西:

ProgressBar bar = (ProgressBar) findViewById(R.id.empty_progress_bar);
bar.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)