To Announcements
IT 372 -- Examples
Table of Contents for Examples
TextDisplay Example:
Magic8Ball Example:
FontSizes Example
InnerClass Example
- InnerClass Example -- Compare behavior of ordinary classes with a class that
contains an inner class. See how an inner class is used to
implement an ActionListener class.
TempConverter Example
- TempConverter Example -- Set up a Button event handler using three different methods:
- Setting the onClick property in the Button widget,
- Defining an explicit OnClickListener derived class,
- Defining an anonymous OnClickListener class.
- Pass in a lambda function to use as the click listener.
BeerAdvisor Example
- BeerAdvisor Example -- Create an app that inputs the beer color
(blond, amber, brown, dark) in a Spinner widgit, then displays four recommended beers for that color.
SendMessage Example
- SendMessage Example -- Create an app with two activities and an intent that starts up the second
activity, passing information to it.
ChangeColors Example
- ChangeColors Example -- Use a
button with an event handler to cycle through these background colors:
LightBlue, LightGreen, LightPink. Set the background as an astronomical nebula
image.
ClickCounter Example
- ClickCounter Example --
Implement a click counter app with a text view initialized to "0" and
two buttons Click Me and Reset. When the Click Me button is clicked,
add one to the text view; when the Reset button is clicked, set the
text view back to "0". When the device is rotated, set the layout to
Landscape and restart the app with the correct number of clicks.
StopWatch Example
- StopWatch Example -- Implement
a stopwatch with Run, Pause, and Reset buttons. Have the layout rotate from
portrait to landscape when the device is rotated.
image.
StudentEntryForm Example
StudentsDb1 Example
- StudentsDb1 Example --
Create an SQLite database, insert one row into it. Then retrieve the
row from the database and display the fields in a textview.
StudentsDb2 Example
- StudentsDb2 Example --
Create an app that enters information into an SQLite database and then
lets the user scroll through the rows of the database.
MonthButtons1 Example
- MonthButtons1 Example -- Use a ScrollView to display 12 buttons, one for each month. In
addition to the text, display an image on the left side of each the button.
Each button has a stub event handler that shows a toast identifying the button
that was clicked.
MonthButtons2 Example
- MonthButtons2 Example -- Use a ScrollView to display 12 buttons, one for each month.
However, for this example, add the buttons dynamically in the activity code.
Also add the event handlers as anonymous methods in the activity code.
Drawing1 Example
- Drawing1 Example -- Set up a derived class
MyView using the base class View.
Override the onDraw method to draw in a
MyView object.
Drawing2 Example
- Drawing2 Example -- This example is similar to Drawing1.
Random circles of various colors are drawn. A Draw Circles button is available to redraw the random circles.
TouchEvent1 Example
- TouchEvent1 Example -- Set up an a touch
event handler that records the locations of touch events in a view.
TouristInfo Example
- TouristInfo Example -- Set up a ListView container
that displays the names of tourist cities (such as Barcelona, London, Paris). When a city name is clicked
start an activity that displays tourist information about that city.
ShowSuit Example
- ShowSuit Example -- Set up radio buttons to select a suit (club,
diamond, heard, or spade) image that will be displayed in an ImageView widget when a
Show Image button is clicked.
DrawStar Example
- DrawStar Example -- Create a MyView widget that
connects the dots to draw a five-pointed star in its
onDraw method.
DrawRivers Example
- DrawRivers Example -- Draw the
rivers used for Project 4. Draw the
rivers in the onDraw method of the MyView
widget using the data in the raw input file rivers.txt.
WriteToFile Example
- WriteToFile Example --
Write to a file in Internal Storage. Write string in EditText
widget to file. Then read from file and display it in a
TextView widget.
ReadFrom Example
RestaurantLocator Example
KotlinPerson1 Example
KotlinPerson2 Example
- KotlinPerson2 Example
-- Implement and test a Person class with explicit backing fields, getters, and setters.
KotlinGreeter Example
- KotlinGreeter Example
-- Input a name in an EditText widget, compose a greeting to the person with that name,
and display the greeting in a TextView widget.
SecretMessage Example
- SecretMessage Example
-- Implement a SecretMessage app with three pages implemented by fragments. The three pages are
(1) Welcome Page: explains what the app will to,
(2) Message Page: inputs a message to encrypt, and
(3) Encrpytion Page: encrypts the message and displays the encrypted message.
This example shows how to manage the fragments and how to pass information from
one fragment to another. Implementing pages as fragments is more modern that
implementing pages with activities and intents.