SmartRefreshLayout上拉刷新下拉加载

首先导入依赖

//SmartRefreshLayout的依赖
    implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-6'

在需要刷新的写入控件


    

    
    

在MainActivity中初始化然后写入方法

smartrefresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                results.clear();
                page =1;
                shoppingPresenter.load(page);
                shopAdapter.notifyDataSetChanged();
                refreshlayout.finishRefresh();
            }
        });
        smartrefresh.setOnLoadmoreListener(new OnLoadmoreListener() {
            @Override
            public void onLoadmore(RefreshLayout refreshlayout) {

                page ++;
                shoppingPresenter.load(page);
                shopAdapter.notifyDataSetChanged();
                refreshlayout.finishLoadmore();
            }
        });

 

你可能感兴趣的:(知识点)