DetailsFragment Overridden Method onCreateView

The onCreateView method (Fig. 8.45) obtains the selected contact’s row ID (lines 70–79). If the Fragment is being restored, we load the rowID from the savedInstanceState bundle; otherwise, we get it from the Fragment’s Bundle of arguments. Lines 82–93 inflate the GUI and get references to the TextViews.

61      // called when DetailsFragmentListener's view needs to be created62      @Override63      public View onCreateView(LayoutInflater inflater, ViewGroup container,64         Bundle savedInstanceState)65      {66         super.onCreateView(inflater, container, savedInstanceState);67         setRetainInstance(true ); // save fragment across config changes68 69          ...

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.