<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <com.scwang.smartrefresh.layout.SmartRefreshLayout android:id="@+id/smart" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- 所有展示的控件都放在smart控件里面 --> </com.scwang.smartrefresh.layout.SmartRefreshLayout> </LinearLayout>
SmartRefreshLayout mSmart = (SmartRefreshLayout) inflate.findViewById(R.id.smart); //更新数据 mSmart.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() { @Override public void onLoadMore(@NonNull RefreshLayout refreshLayout) { refreshLayout.finishLoadMore(2000); } @Override public void onRefresh(@NonNull RefreshLayout refreshLayout) { refreshLayout.finishRefresh(2000); //1.先清空原来的数据,,,重新加载数据 2.调取加载数据的方法 } });
文章来源: SmartRefreshLayout 刷新数据