依赖
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.3'
XML
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/sr"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
上拉刷新下拉加载
private void initListener() {
sr.setOnRefreshListener(this);
sr.setOnLoadmoreListener(this);
}
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
initData();
sr.finishLoadmore();
}
@Override
public void onRefresh(RefreshLayout refreshlayout) {
data.clear();
sr.finishRefresh();
initData();
adap.notifyDataSetChanged();
}