To Lecture Notes

IT 372 -- Apr 28, 2025

Review Exercises

  1. How do you add a new activity to an Android project?
  2. How are the Intent and a Bundle objects used?
  3. Create an Android app named Greeter with three activities named MainActivity, Greeter2Activity, and Greeter3Activity. MainActivity displays the greeting
    Hello, how are you?
    Click for next activity.
    
    Greeter2Activity displays the message
    I'm fine, thank you, and you?
    Click for next activity.
    
    Greeter3Activity displays the message
    I'm fine too, thanks.
    Click for main activity.
    
    Implement the onClick event handlers with lambda functions (Method 4).
    Ans: Here are the source code files:
    activity_main.xml   MainActivity.java
    activity_greeter2.xml  Greeter2Activity.java
    activity_greeter3.xml  Greeter3Activity.java
  4. What does a ConstraintLayout constraint look like?

Writing to the Logcat Window

The Android Studio IDE

Practice Problems

  1. Create an Android app with project name DonorInfo and two activities MainActivity and DisplayActivity. The MainActivity layout should have two EditText widgets for entering donor name and donation amount and a submit button. Use an ArrayList collection to record the names and amounts. When the button is clicked, record the name and amount in the arraylist, then display all of the information in the array in an EditText widget located in the DisplayActivity. Create a string to put in the Intent object, something like this:
    "Tom,2000.00;Anna,1500.00;Terry,2300"
    
    Answer: Here are the resulting source code files:
        activity_main.xml  MainActivity.java  activity_display.xml
        DisplayActivity.java  Donation.java  strings.xml
  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.

Debugging Android Apps

Android Platform and Architecture

Adding Widgets Dynamically

Responding to Touch Events