1

I am developing and application that will have to implement the swipe-to-refresh pattern described here. Looking at the android docs here, it is stated that:

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.

Well the issue is that I do not plan on having a ListView or GridView to layout my data, I am using cards (android.support.design.CardView) and I am planning on having a scrolling list of cards that the end user can swipe to refresh.

Can I still use the SwipeToRefreshLayout as described in the tutorial with my cards, or does it force me to use ListViews or GridViews to display my data?

James Parsons
  • 6,097
  • 12
  • 68
  • 108

1 Answers1

1

Well as the documentation says that

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.

It does not mention that the view must be a ListView or a RecyclerView.

Also as seen in those questions:

SwiperefreshLayout in Android

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

Both of them have implemented a SwipeRefreshLayout with LinearLayout as the child View. So yes it will work with the view either being a CardView or a ScrollView.

Hope it helps!!!

Community
  • 1
  • 1
Kostas Drak
  • 3,222
  • 6
  • 28
  • 60