SwipeRefreshLayout 下拉刷新


<androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.realm.RealmDemo">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:id="@+id/swipe_refresh_layout">

        <androidx.recyclerview.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent" android:id="@+id/recycle_view"/>

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>


</androidx.constraintlayout.widget.ConstraintLayout>

使用比較簡單 這里就模擬了一下加載效果 下拉觸發加載顯示動畫此時isRefreshing=true   加載數據后需要修改為false 隱藏動畫

swipe_refresh_layout.isRefreshing = false
        swipe_refresh_layout.setOnRefreshListener {
            Handler().postDelayed({
                swipe_refresh_layout.isRefreshing = false
            },2000)
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM