To Lecture Notes

IT 372 -- Apr 20, 2026

Review Questions

  1. Look again at the Activity Lifecyle Section of the April 15 notes. Create the LifeCycle app that writes these strings to the Logcat Window for each corresponding method that executes:
    In onCreate method.
    In onStart method.
    In onResume method.
    In onPause method.
    
  2. Look at the ClickCounter Example.
  3. Look at the StopWatch Example.
  4. Look at the SendMessage Example. This example shows how to add a second activity to an app.
  5. Set up a LinearLayout form to input grocery item data with these fields: description (String), code (int), and price (double). When the Submit Grocery Item button is clicked, contatenate the information to the String variable groceryItems that is displayed on a new activity. Answer:
         activity_main.xml  MainActivity.java
         activity_display_items.xml  DisplayItemsActivity.java
    When the virtual device is rotated, save the groceryItems variable in a Bundle object so that this variable can be restored when the activity is recreated after the activity is destroyed due to device rotation.
    Ans: Main activity after adding onSaveInstanceState method and statements in onCreate to restore bundle.
         MainActivity.java
  6. Create an app named ShowSuit. Add a radiobutton group with four radio buttons and an ImageView widget to the ConstraintLayout. Set the text for the radio buttons to Club, Diamond, Heart, and Spade. Set up an onCheckedChangeListener event handler that changes the image of the imageview to club.png, diamond.png, heart.png, or spade.png, depending on the radiobutton that is clicked. Here is a zipfile of the suit images.  Use an anonymous inner class to set up the event handler.
    Ans: Copy the suit images files into the res/drawable folder. Here are the layout and activity files.
  7. Write apps that test these widgets: SeekBar and CalendarView.

Android Platform