将滑动刷新添加到卡片列表

Adding swipe-to-refresh to a list of cards

我正在开发的应用程序必须实现 here. Looking at the android docs here 中描述的滑动刷新模式,据说:

You enable this behavior by adding the widget to your layout file as the parent of a ListView or GridView, and implementing the refresh behavior that gets invoked when the user swipes.

好吧,问题是我不打算使用 ListViewGridView 来布局我的数据,我正在使用卡片 (android.support.design.CardView) 并且我打算使用最终用户可以滑动刷新的卡片滚动列表。

我是否仍可以按照教程中的说明使用我的卡片 SwipeToRefreshLayout,还是强制我使用 ListViews 或 GridViews 来显示我的数据?

正如 documentation 所说

The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. This layout should be made the parent of the view that will be refreshed as a result of the gesture and can only support one direct child.

它没有提到视图必须是 ListViewRecyclerView

也如在这些问题中所见:

SwiperefreshLayout in Android

Android SwipeRefreshLayout how to implement canChildScrollUp if child is not a ListView or ScrollView

他们俩都实现了 SwipeRefreshLayoutLinearLayout 作为 child View。所以是的,它将与 CardViewScrollView.

的视图一起使用

希望对您有所帮助!!!