Issue
What is the reason behind having lifecycle methods of Activity as protected while life cycle methods of fragments are public. I read on link lifecycle methods but couldn't got clear idea. Please explain.
Solution
A Fragment
is meant to be hosted by an Activity
. This means that the host (activity) is responsible of updating the state of it's hosted items (fragments). This will include calling the corresponding lifecycle methods of the fragment instances in accordance with the changes in the activity lifecycle. In order for those methods to be called by classes, external to the whole Fragment
class hierarchy, they have to be public
.
Answered By - Danail Alexiev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.