-1

How can I pass a list of objects retrieved in activity with retrofit 2, to a fragment using new instance pattern, would someone have an implementation example?

1 Answers1

0

Your objects will need to support Parcelable so they can be added to a Bundle. In your Fragment, create a static method, newInstance which takes your input arguments as appropriate (such as a List of them.) In the newInstance method, create a Bundle and add your argument objects to it, then create an instance of your Fragment using new. Before returning the new Fragment instance, call .setArguments() and pass it the Bundle.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33