5.6 MainActivity Class

This app consists of six classes:

  • MainActivity (discussed below)—This is the parent Activity for the app’s Fragments.

  • MainActivityFragment (Section 5.7)—Manages the DoodleView and accelerometer event handling.

  • DoodleView (Section 5.8)—Provides the drawing, saving and printing capabilities.

  • ColorDialogFragment (Section 5.9)—A DialogFragment that’s displayed when the user chooses the option to set the drawing color.

  • LineWidthDialogFragment (Section 5.10)—A DialogFragment that’s displayed when the user chooses the option to set the line width.

  • EraseImageDialogFragment (Section 5.11)—A DialogFragment that’s displayed when the user chooses the option to erase, or shakes the device to erase, the current drawing.

Class MainActivity ...

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.