依賴
//上拉下拉
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.4-7'
刷新
//刷新
smart.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
circlePresenter.onCirclePresenter(page,count);
circleAdapter.notifyDataSetChanged();
smart.finishRefresh();
}
});
//加載
smart.setOnLoadmoreListener(new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
page++;
count++;
for (int i = 0; i <5; i++) {
circlePresenter.onCirclePresenter(page,count);
}
refreshlayout.finishLoadmore();
}
});
smart.setEnableRefresh(true);//刷新
smart.setEnableLoadmore(true);//加載
//關閉
smart.finishRefresh();
smart.finishLoadmore();
佈局
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/smart"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/circle_recy"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
shape繪製
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
//背景顏色
<solid android:color=" #AAAAAA"/>
//設置邊框線的粗細和顏色
<stroke
android:width="0.03dp"
android:color="#dddd"
/>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"
/>
<corners android:radius="25dp"/>
</shape>