在一些数据加载界面之中,我们经常需要加入分页来范围内也获取数据,无法避免加入下拉和上拉刷新数据,在RecycleView中可以通过SwipeRefreshLayout来实现界面的下拉刷新,并通过监听RecycleView的滑动事件来达到下拉刷新的效果。
布局
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshView"
android:layout_width = "match_parent"
android:layout_height = "match_parent" >
<android.support.v7.widget.RecyclerView
android:id = "@+id/rv_list"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background = "@color/white" />
</android.support.v4.widget.SwipeRefreshLayout >
1.下拉刷新
//设置下拉刷新dialog的颜色
refreshView.setColorSchemeColors(context.getResources().getColor(R.color.gre