为ListView设计数据为空的View

来源:互联网 发布:directx9修复软件64位 编辑:程序博客网 时间:2024/05/29 18:24

第一步:将无数据的View与ListView静态布局到RelativeLayout中


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" >


            <ListView
                android:id="@+id/id_list_querytrouble"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />


            <ImageView
                android:id="@+id/iv_bg_notrouble"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/bg_notrouble" />
        </RelativeLayout>


第二步:在ListView数据为空的时候设置mListView.setEmptyView(iv_bg_notrouble);

0 0