【已过时,不再更新,请使用更强大的SmartRefreshLayout!】A refresh layout(无侵入下拉刷新和加载布局), can refresh RecyclerView for all LayoutManager, NestedScrollView。
A refresh layout, can refresh RecyclerView for all LayoutManager, NestedScrollView and Any View that implements NestedScrollChild !
refresh RecyclerView for StaggeredGridLayoutManager :
refresh RecyclerView for GridLayoutManager :
refresh RecyclerView for LinearLayoutManager :
refresh NestedScrollView :
custom refresh animation! There is two animation style now, I will support more animation in future...
dependencies {
compile 'com.lxj:xrefreshlayout:0.0.1'
}
make your layout
<com.lxj.xrefreshlayout.XRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/xrefreshLayout"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.lxj.xrefreshlayout.XRefreshLayout>
或者
<com.lxj.xrefreshlayout.XRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/xrefreshLayout"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.lxj.xrefreshlayout.XRefreshLayout>
set refresh listener
xrefreshLayout.setOnRefreshListener(new XRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
}
@Override
public void onLoadMore() {
}
});
finish refresh
xrefreshLayout.completeRefresh();
set custom loadinglayout
//you can see the DefaultLoadingLayout for some help.
xrefreshLayout.setLoadingLayout(...);