Android Fragment onCreateView vs. onActivityCreated

If your view is static, then moving any code to the onActivityCreated method is not necessary. But when you – for instance, fill some lists from the adapter, then you should do it in the onActivityCreated method as well as restoring the view state when setRetainInstance used to do so.

Also accessing the view hierarchy of the parent activity must be done in the onActivityCreated, not sooner.

Leave a Comment