Android的 - 自动解雇进度条 [英] Android - dismiss progress bar automatically

查看:161
本文介绍了Android的 - 自动解雇进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序启动时,我从膨胀的进度条的main.xml 这是显示,直到该列表为空文件。一旦列表中填充是从URL来的数据,我应该关闭该进度条。
我怎样才能做到这一点,而无需使用进度对话框?

我的main.xml

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    工具:上下文=MainActivity。>    < ListView控件
        机器人:ID =@ + ID / list_view_places
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:layout_weight =1
        机器人:drawSelectorOnTop =假
        机器人:fastScrollEnabled =真正的>
    < /&的ListView GT;    <进度
        机器人:ID =@ + ID / empty_progress_bar
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_centerInParent =真/>< / RelativeLayout的>


解决方案

尝试是这样的:

 进度栏=(进度)findViewById(R.id.empty_progress_bar);
bar.setVisibility(View.GONE);

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>

解决方案

Try something like:

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

这篇关于Android的 - 自动解雇进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆