AddEditFragment Overridden Method onCreateView

In method onCreateView (Fig. 8.38), lines 70–78 inflate the GUI and get the Fragment’s EditTexts. Next, we use Fragment method getArguments to get the Bundle of arguments (if any). When we launch the AddEditFragment from the MainActivity, we don’t pass a Bundle, because the user is adding a new contact’s information. In this case, getArguments will return null. If it returns a Bundle (line 82), then the AddEditFragment was launched from the DetailsFragment and the user chose to edit an existing contact. Lines 84–91 read the arguments out of the Bundle by calling methods getLong (line 84) and getString, and the String data is displayed in the EditTexts for editing. Lines 95–97 register a listener ...

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.