Android - dismiss progress bar automatically

落花浮王杯 提交于 2019-12-24 16:34:00

问题


when the app is launched, I inflate a progress bar from main.xml file which is shown until the list is empty. Once the list is populated with data which is coming from URL, i should dismiss this progress bar. How can i do this without using progress dialog?

my 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>

回答1:


Try something like:

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



回答2:


If you will use list fragment then progress bar is automatically handled. once data is populated it will automatically dismiss.




回答3:


Try this :
globalProgressDialog.dismissProgressDialog();


来源:https://stackoverflow.com/questions/14854457/android-dismiss-progress-bar-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!