O'Reilly logo

Android™ How to Program, Second Edition by Abbey Deitel, Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required