To Examples
DrawRivers Example
Goal
- Draw the rivers used for Project 4. Read the rivers data from the input file
rivers.txt.
Then draw the rivers in the onDraw method of the MyView
widget.
Emulator Screen Shot
Directions
- Create an Android project named DrawRivers. Replace the default layout and activity files with these
files:
activity_main.xml
MainActivity.java
- Add the new named directory raw to
app/src/main/res
- Add the new file rivers.txt to the raw folder.
- The field isStartPoint is used to mark where a new curve starts. If
startPoint is 0, connect the current point
(x, y) to the previous point (prevX, prevY). If startPoint is 1, don't connect to the previous point.
- Add the new class named MyView to the project. Replace its code with:
MyView.java