To Lecture Notes

IT 372 -- May 27, 2026

Review Exercises

  1. Set up a demonstration JPC app with TextField and Text elements and state variable defined by
    var textValue = remember { mutableStateOf("") }
    
    Show how to change = to by in this statement; in particular, how to set up the getter and setter for textValue.
  2. Show that using
    modifier = Modifier
        .padding(all=40.dp)
        .background(color = Color(0xFFC0C0C0))
    
    to style a Column element gives a different result than using
    modifier = Modifier
        .background(color = Color(0xFFC0C0C0))
        .padding(all=40.dp)
    
  3. How do you write to and read from an internal file on the emulator or device? Consider the two cases of reading the entire file into a string and reading the file line by line. Also consider the two cases of overwriting the file the file or appending to the file.
  4. Modify the TouchPoint Example to draw multiple circles positioned by touch points on a canvas. Store the locations of the points in a MutableStateList of Offset objects.
  5. Set up this trianglePath state variable:
    val trianglePath = remember {
        Path().apply {
            moveTo(600f, 400f)
            lineTo(600f, 800f)
            lineTo(200f, 900f)
            close()
        }
    }
    
    Then define this Canvas element that draws a filled triangle:
    Canvas(modifier = Modifier.fillMaxSize()) {
        drawPath(
            path = trianglePath,
            color = Color.Blue
        )
    }
    
    Modify the Exercise 3 to draw a polygon using touch events.
  6. Try out the drawOval method in a Canvas element. Use these parameters:
    color : Color
    topLeft : Offset(x : Float, y : Float)
    size : Size(width : Float, height : Float)
    style : Fill or Stroke(Float)
    
  7. Modify the Proj4Exb Example to use CustomButton elements for the three buttons. Use these parameters: caption : String and onClick : ( ) -> Unit.

JetPack Compose Examples

Android Platform