ListView分页功能(3) 解决使用footerView数据不足,显示问题

154 阅读1分钟

ListView分页功能(3)  解决使用footerView数据不足,显示问题

在listvie分页功能(1)中使用addFooterView(view)出现数据不足,加载布局显示在数据后面,影响数据(并不在底部)

使用addFooterView的问题

另外建一个底部布局 include在主布局的内部:

底部布局:layout_footer:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:visibility="gone" >

    <LinearLayout
        android:id="@+id/ll_bottom"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#A7C0DC"
        android:gravity="center"
        android:orientation="horizontal" >

        <ProgressBar
            android:id="@+id/progressbar"
            android:layout_width="32dp"
            android:layout_height="32dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="正在加载。。。"
            android:textSize="22sp" />
    </LinearLayout>

</LinearLayout>

添加到主布局中

使用<include>将layout_footer布局添加到主布局的底部,

使用android:layout_alignParentBottom="true" 设置在底部显示。

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

    <com.example.listviewpagedemo.MyListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <include
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        layout="@layout/footer" />

</RelativeLayout>


主要的方法与ListView分页功能(2)基本相同,只是改变了加载布局的显示。

\

\