一、在build.gradle中导入依赖库: implementation ‘androidx.appcompat:appcompat:1.0.0’ //1.0.0 以上 implementation ‘com.scwang.smart:refresh-layout-kernel:2.0.3’ //核心依赖 implementation ‘com.scwang.smart:refresh-header-classics:2.0.3’ //经典刷新 implementation ‘com.scwang.smart:refresh-footer-classics:2.0.3’ //经典加载
二、布局文件中导入刷新布局框架
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F1EBEB"
app:srlAccentColor="@android:color/black"
app:srlEnablePreviewInEditMode="true"
app:srlPrimaryColor="#EFEDED"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search_bar_bottom_divider">
<com.scwang.smart.refresh.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:name="com.byd.intermap.mvp.main.view.SearchFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffff"
app:layoutManager="LinearLayoutManager"
tools:context=".mvp.search.SearchFragment"
tools:listitem="@layout/search_input_tips_item" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|