滑动时显示加载图标,但没有任何反应, 这是我的代码:
<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>
答案 0 :(得分:4)
将其单独添加到布局不会执行任何操作,您必须使用Kotlin代码处理刷新事件:
swiperefresh.setOnRefreshListener {
reloadListData() // refresh your list contents somehow
swiperefresh.isRefreshing = false // reset the SwipeRefreshLayout (stop the loading spinner)
}