Android Fragments over layout inflation -
i know fragments used making flexible uis. once asked advantage of using fragment on layout inflation. in other words can inflate our custom layout file(one inflate representing fragment ui) container layout of backing activity. why use fragments instead?
in opinion fragments used on layout inflation better designing purpose has own lifecycle methods. can give me better answer this.
fragments intercept activity's lifecycle events (oncreate(), onstart(), onresume(), etc). because of fragments can save , resume state , data when activity destroyed , recreated. may not save data of ui, when user rotate phone. fragment you.
also fragments useful when want separate ui units.
and fragments may create own class builds in activity's lifecycle.
of course may same without fragments, believe google developed fragments in order improve our life , increase efficiency of our working.
Comments
Post a Comment