To Lecture Notes

IT 372 -- Apr 10, 2024

Review Exercises

  1. What does the Android R class do?
    Answer: It manages the resources in an Android app, for example: ids, colors in the colors.xml file and strings in the strings.xml file.  You can use the id to create a Java object like this:
    TextView tv = findViewById(R.id.txt_temp);
    
  2. Show how display a string dynamically from the strings.xml resource file. Answer:
    TextView tv = findViewById(R.id.txt_name);
    tv.setText(getString(R.string.first_name));
    
  3. Show how to change a color dynamically from the colors.xml resource file. Answer:
    LinearLayout layout = findViewById(R.id.main);
    layout.setBackgroundColor(getColor(R.color.purple));
    // or
    layout.setBackgroundColor(0xFFFF00FF);
    

Magic8Ball Example

Project 1b

InnerClass Example

A Simple Interface

Android Event Handlers

Project 2