How to set data for fragments (setArgumets () vs seters method)

Is it mandatory to set data using a package and a given argument? What is wrong here?

MyFragment frag = new MyFragment ()
frag.setData(mSchoolData);

//add to back stack stuff.
+4
source share
1 answer

using setArgs (), you will see that this fragment can be recreated due to a life cycle event ... while by passing arguments with your own setters it may not work correctly on certain cycles. That is why it is absolutely recommended to use either Args OR or Intent add-ons, they will always be automatically provided by the system if the fragment is recreated.

+5
source

All Articles