1.首先在应用或模块的 build.gradle
文件中添加所需工件的依赖项:
dependencies {
implementation “androidx.swiperefreshlayout:swiperefreshlayout:1.0.0”
}
2.在xml文件里面添加相关代码
<?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”>
<android.support.v4.widget.SwipeRefreshLayout>
</android.support.v4.widget.SwipeRefreshLayout>
3.添加布局代码
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.SwipeRefreshLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:orientation=“vertical”