Android ---------- 下拉刷新,上拉加载

视图布局部分:

<com.Widget.StateFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
app:dataErrorLayoutResId="@layout/widget_dataerror"
app:emptyLayoutResId="@layout/widget_dataempty"
app:loadingLayoutResId="@layout/widget_data_loading"
app:needLoginLayoutResId="@layout/widget_needlogin"
app:netErrorLayoutResId="@layout/widget_neterror"
app:timeOutLayoutResId="@layout/widget_timeout"

>
<com.Widget.ASwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.Widget.ASwipeRefreshLayout>

</com.Widget.StateFrameLayout>

控制器部分:
// 设置上拉加载更多
swipelayoutyoudan.setOnLoadMoreListener(new ASwipeRefreshLayout.OnLoadMoreListener() {
@Override
public void onLoadMore() {
pageindex+=1;
requestData(false);
}
});
//设置下拉刷新
swipelayoutyoudan.setOnRefreshListener(new ASwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
pageindex=1;
requestData(false);
}
});




原文地址:https://www.cnblogs.com/apeandcat/p/8390660.html