When to use onCreateView() vs onActivityCreated()?

Asked

Viewed 231 times

1

I wanted to know the questions below:

-When using onCreateView() vs onActivityCreated()?

-Which of these two methods should I use to fill a listview with Adapter?

1 answer

0


The onCreateView() is used when you want to create a Fragment custom. Beware, if you use it to create a view because later, you need to destroy this object by calling the onDestroyView(). It is always executed before the onActivityCreated().

The onActivityCreated() is called after the previous informing that a Fragment View has been instantiated.

About which to use to fill a Listview, use the onCreateView() for the onActivityCreated() is more to recover the state of objects already created.

That last description I did not test!

  • 1

    Beware, the method onDestroyView is not to be called. He is already called by FragmentManager during the destruction ofView according to the life cycle of Fragment.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.