ContactListFragment Overridden Method onViewCreated

Recall that class ListFragment already contains a ListView, so we don’t need to inflate the GUI as in previous app’s Fragments. However, class ContactListFragment has tasks that should be performed after its default layout is inflated. For this reason, ContactListFragment overrides Fragment lifecycle method onViewCreated (Fig. 8.27), which is called after onCreateView.

53      // called after View is created54      @Override55      public void onViewCreated(View view, Bundle savedInstanceState)56      {57         super.onViewCreated(view, savedInstanceState);58         setRetainInstance(true ); // save fragment across config changes 59         setHasOptionsMenu( ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.