6.7 MainActivityFragment Subclass of Fragment

Class MainActivityFragment (Fig. 6.6) overrides four Fragment methods:

Fig. 6.6 MainActivityFragment creates and manages the CannonView

Computer code has 52 lines.

Fig. 6.6 MainActivityFragment creates and manages the CannonView

Code continues.
  • onCreateView (lines 17–28)—As you learned in Section 4.3.3, this method is called after a Fragment’s onCreate method to build and return a View containing the Fragment’s GUI. Lines 22–23 inflate the GUI. Line 26 gets a reference to the

Get Android How to Program, 3/e 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.