android - FragmentManager.put/getFragment vs findFragmentByTag -


more point, in oncreate/oncreateview calling fragmentmanager.findfragmentbytag() lookup existing instance of fragment, , seems find it.

so point of putfragment/getfragment? save or cause additional lifecycle stuff happen? alternative findfragmentbytag() more or less same thing? because seems me fragment being automatically saved me without needing use fragmentmanager.putfragment().

so point of putfragment/getfragment?

according current implementation, putfragment(bundle bundle, string key, fragment fragment) put index of fragment bundle parameter key. , getfragment(bundle bundle, string key) fragment @ same index can retrieved bundle same key. fragment has index in fragmentmanager after added it, putfragment() can called on fragment after added.

does save or cause additional lifecycle stuff happen?

it save index of fragment only, no more things else, nor cause additional lifecycle stuff.

is alternative findfragmentbytag() more or less same thing?

yes, thik so.

according current implementation, putfragment/getfragment can achieved findfragmentbytag() too. function of putfragment/getfragment quite limited because can't use them without bundle parameter, means must call putfragment() in onsaveinstancestate().


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -