Android RecyclerView 各种刷新实现思路

  1.BaseRecyclerViewAdapterHelper  里边有上拉下拉的  上拉可能有问题 所以 直接换别的比如Google的SwipeRefreshLayout,或者SmartRefreshLayout,https://github.com/scwang90/SmartRefreshLayout#1  .

2.

compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1'
compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.5.1'//没有使用特殊Header,可以不加这行
 <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srlAccentColor="#00000000"
        app:srlEnablePreviewInEditMode="true"
        app:srlPrimaryColor="#00000000">

        <com.scwang.smartrefresh.layout.header.ClassicsHeader
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <com.scwang.smartrefresh.layout.footer.ClassicsFooter
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </com.scwang.smartrefresh.layout.SmartRefreshLayout>
 refreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                list.add("我是新加的RefreshLayout");
                myAdapter.notifyDataSetChanged();
                refreshLayout.finishRefresh();
            }

            @Override
            public void onLoadMore(RefreshLayout refreshLayout) {
                list.add("我是新加的onLoadMore");
                myAdapter.notifyDataSetChanged();
                refreshLayout.finishLoadMore();
            }
        });

 

猜你喜欢

转载自blog.csdn.net/FlyPig_Vip/article/details/82660851
今日推荐