To Lecture Notes

IT 372 -- May 13, 2024

Review Questions

  1. What are the steps to adding a widget dynamically to a linear layout
  2. In the Android Class Library, look up the documentation for the TextView class.
    Answer: The package for the TextView class is android.widget. To find the documentation, go to
    android.developer.com.  Select
          More >> Develop >> Android Platform (in Libraries)
    Find the TextView class.
  3. Look up methods from the Canvas class in the Android Developer class docmentation. The package name is android.graphics. The Canvas class contains methods for drawing shapes. Here are some of its methods to check out:
    drawCircle  drawOval   drawLine  drawPath
    drawPoint  drawPoints  drawRect   
    
  4. Write an Android app that draws a circle in a MyView widget when a touch up event occurs. Hint: combine the Drawing0 and TouchEvent1 examples.
  5. Repeatedly draw circles with touch up events. Keep track of the locations of the circles in Point objects stored in an arraylist. Here is the UML diagram for the Point class:
    +---------------------------+
    |          Point            |
    +---------------------------+
    | - x: int                  |
    | - y: int                  |
    +---------------------------+
    | + Point(x : int, y : int) |
    | + getX( ) : int           |
    | + getY( ) : int           |
    | + toString( ) : String    |
    +---------------------------+
    
  6. To the app in Exercise 5, add a reset button to erase all circles and start over.
    Ans: activity_main.xml   Point.java   MyView.java   ActivityMain.java
  7. In Exercise 6, instead of drawing circles, draw a polyline (connected line segments).
  8. Research and test this widget: SeekBar.
    Ans: Here are the layout and activity files:
         activity_main.xml   MainActivity.java
  9. Look at the DrawStar Example.

Project 4

Read from File

Draw Rivers Example

ZooMap App