To Lecture Notes

IT 372 -- Apr 30, 2025

Review Questions

  1. Add a TextView widget to a constraint layout. Change the font family of the widget using the Design Layout Editor. Check out these files that are modified:
    res/activity_main.xml      res/font/font_name.(ttf | xml)
    res/values/font_certs.xml  res/values/preloaded_fonts.xml
    
    Answer: Use the Design Editor to select the fontFamily attribute. You can either use one of the predefined fonts,
  2. 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.
    Answer: Copy the suit images files into the res/drawable folder. Here are the layout and activity files. Also, see the ShowSuit Example for a different implementation of this problem.
  3. Set up a main activity with a Spinner containing the names of birds, and two Button widgets. The first button has the caption Add Bird; the second button has the caption Display Birds in ArrayList. When first button is clicked the selected bird in the spinner is added to the arraylist. When the second button is clicked, the birds arraylist is passed to a new activity, an output string is created from the birds in the arraylist, and the output string is displayed in a textview.
    Answer: Here are the app files:
          activity_main.xml  strings.xml   MainActivity.java
          activity_show_birds.xml  ShowBirdsActivity.java

Debugging Android Apps

Android Platform and Architecture

Adding Widgets Dynamically

Responding to Touch Events