0

when swipe it shows loading icon, but nothing happens than, here is my code:

 <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swiperefresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_main"
            android:layout_width="368dp"
            android:layout_height="495dp"
            android:layout_marginBottom="16dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp" />

    </android.support.v4.widget.SwipeRefreshLayout>
  • 1
    Possible duplicate of [How to use the SwipeRefreshLayout?](https://stackoverflow.com/questions/23014846/how-to-use-the-swiperefreshlayout) – Shubham AgaRwal Sep 08 '18 at 09:14

1 Answers1

4

Adding that to your layout on its own does nothing, you have to handle the refresh event in your Kotlin code:

swiperefresh.setOnRefreshListener { 
    reloadListData()                    // refresh your list contents somehow
    swiperefresh.isRefreshing = false   // reset the SwipeRefreshLayout (stop the loading spinner)
}
zsmb13
  • 85,752
  • 11
  • 221
  • 226