FrameLayout 程序界面预加载

适用范围:listview显示的项目为耗时的加载操作
如:获取系统安装程序,从服务器上下载并显示消息或内容
1.定义布局文件

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

        <!--
       android:cacheColorHint="#00000000" 缓存的颜色  默认是黄色
       android:divider="#00ffffff" 分割线
       android:dividerHeight="3.0dip" 分割线的宽度
        -->
<ListView
   android:id="@+id/lv_appmanage"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:cacheColorHint="#00000000"
   android:divider="#fff"
   android:fastScrollEnabled="true"
   android:dividerHeight="1.0dip"
   android:paddingLeft="3.0dip"
   android:paddingRight="3.0dip" />

<RelativeLayout
    android:id="@+id/rl_loading"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
       <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_centerInParent="true">
            <ProgressBar
                    android:id="@+id/pb"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    />

            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:text="正在加载应用程序。。"
                    android:textColor="#fff"
                    android:textSize="22sp" />
            </LinearLayout>
        </RelativeLayout>
</FrameLayout>


2.activity中控制隐藏或显示

//找到相应的布局组件
RelativeLayout rl_loading = (RelativeLayout) findViewById(R.id.rl_loading);
//设置相应的显示状况
//View.VISIBLE (控件显示)View.INVISIBLE(控件隐藏  但占据空间) 
//View.GONE(控件隐藏  不占据空间)
rl_loading.setVisibility(View.GONE);


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值