1添加依赖
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.3'//没有使用特殊Header,可以不加这行
compile 'com.android.support:appcompat-v7:25.3.1'//版本随意(必须)
2xml布局
<com.scwang.smartrefresh.layout.SmartRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refreshLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:background="@color/beijing"
android:layout_width="match_parent"
android:layout_height="28px" />
<ListView
android:id="@+id/lv_touzi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="2px"
android:divider="#e8ebeb"/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
中间可随便添加 添加text等。
3代码设置header和footer
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout2);
//设置 Header 为 Material样式
refreshLayout.setRefreshHeader(new WaterDropHeader(this));
//设置 Footer 为 球脉冲
refreshLayout.setRefreshFooter(new BallPulseFooter(this));
刷新和加载方法:
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
progressquery(PAGENO);
refreshlayout.finishRefresh(2000);
}
});
refreshLayout.setLoadmoreFinished(true);
refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
if (PAGENO < mTotalPages) {
PAGENO++;
if (tag == true) {
progressquery(PAGENO);
refreshlayout.finishLoadmore(2000);
}
}
}
});
这样就大功告成了!!!
谢谢大家~~