Hussein Al-maani
Hussein Al-maani

Reputation: 41

SwipeRefreshLayout not working on android version 22 and down

Good day everyone , I want to ask why I can't create SwipeRefresh on RecycleView. It works fine on Marshmallow only , it destroys the app in another version here is Screenshot of logcat Image below

Upvotes: 0

Views: 234

Answers (1)

Eugen Pechanec
Eugen Pechanec

Reputation: 38223

From your logcat:

  • You're using native fragments (android.app.Fragment)
  • On Marshmallow fragments are slightly more complex and introduced getContext() method, which is not present on earlier platforms.
  • I don't know of any practical case where getContext() returns a different thing from getActivity().

Use getActivity() instead of getContext().

It's worth noting that this has nothing to do with the SwipeRefreshLayout itself. You just used wrong method call in the OnRefreshListener callback.

Upvotes: 1

Related Questions