Tutorial Exercises:
- Following the Spinner example in Lecture 4 create an app with a list of pizzas.
Eg. Ham and pineapple, Supreme, Seafood, Italian, Meat lovers etc. Upon
selecting one from the spinner list a Toast should pop up indicating the choice. - Reproduce the same action as in question 1 using a ListView.
- Modify your app from exercise 2 to include a suitable image. You will have to
find images and copy them into the res/drawable or mipmap folder in Android
Studio. Include a custom adapter so as to display a star image next to the items
such as “Supreme” and “Seafood” to indicate these are “on special”. - Modify your app from exercise 2 to include a checkbox in each list item so that
when the user clicks on a list item the checkbox is “ticked”. Add these choices to
an array so that you can display the results upon the click of a button on your
interface.
Tutorial Exercises:
- Starting with a basic activity, create a new Java class (use File->New->Java class)
called DataBaseManager as in Lecture 5 and create a database table in SQLite, called
StudentInfo. The fields for the StudentInfo table include StudentID, FirstName,
LastName, YearOfBirth and Gender. Include functions for adding a row to the
table and for retrieving all rows, similar to that shown in lecture 5. No user interface
is required for this question, that is in question 2. - Continuing from question 1, follow the example in the lecture notes 5, create a menu
(or action bar items) for “Add A Record” and “View Records”. When the menu item
“Add A Record” is selected, the program shows a form for entering student
information. The data will be added into the database table StudentInfo. When the
menu item “View Records” is selected, the program shows all records of all students. - Following lecture notes 5, you are required to implement an app that writes to a file
any text from an editText on screen then reads back from the text file and displays the
text on the screen in a textView. - Begin a new app and create a Java class for products with data: productName,
productCode and price and use a file of objects to store product data and read back
and display on screen. Do this by creating a simple form using EditTexts, buttons or
ActionBar items and display output using an Alert.
Tutorial Exercises:
- Write a program whose interface has several large images of your choice (e.g. the
combination of images should be larger than the screen resolution). You are required to
include a scroll view (both horizontal and vertical) for viewing these images. - Write a program that includes 4 buttons called Start, Q1, Q2, Q3 and Complete as well as a
progress bar. When a button is clicked, the progress bar will change its progress indicator to
0%, 25%, 50%, 75% and 100% respectively. - Write a program that includes two buttons called plays Play and Stop. When the Play button
is press, the program will play an audio file. When the Stop button is press, the program will
stop playing the audio file. - Create a GridView as described in Lecture 4 so that a grid of small images (thumbnails) is
displayed on an activity screen. Set up code so that if a user clicks on a thumbnail a new
activity is started which displays the full image.
Tutorial Exercises:
- Write a program to draw a simple chart of three series of numbers: series1 = {-1,
5, 10, 8, 7, 2, 6}, series2= {4, 6, 20, 8, -2, 10, 5} and series3= {3, 7, 21}. - Based on the example “Animations” source code, improve the “Zooming a View”
example so that it shows a thumbnail of 8 small photos, and the photos will
expand when touching the small ones. - Work on assignment 1 and use the time to sort out any remaining issues.
Tutorial Exercises:
- Follow the lecture 8 notes, re-implement a Hello World App. Start by selecting a
SingleView Application. Your app should have a button and a label on the screen.
When the button is pressed the label should show: “Hello Joe” for example. - Following the example in Lecture 9 create an app with a TextField control for a
person’s name and a Switch for choosing their gender. Include appropriate labels
for these controls and add a button for displaying the result after the user has
entered their data. The result can be displayed in another label or an alert (see
Lecture 9). - Modify your app from exercise 2 to use a segmented control instead of a switch
for selecting the gender. - Create a new app and add a NavBar and a Toolbar to the ViewController. Add
BarButton items to these bars and set up functions to respond to presses on these
buttons. The responses can be either alerts or text appearing in labels on the
ViewController.
Tutorial Exercises:
- Following the PickerView example in Lecture 10 create an app with a list of
pizzas. Eg. Ham and pineapple, Supreme, Seafood, Italian, Meat lovers etc. Upon
selecting one from the picker an Alert should pop up indicating the choice. - Reproduce the same action as in question 1 using a TableView.
- Modify your app from exercise 2 to include a suitable pizza image. You will have
to find images and copy them into the xcassets folder in Xcode. Modify the code
so as to display a star image next to the items such as “Supreme” and “Seafood”
to indicate these are “on special”. - Rework exercise 2 with custom (prototype) TableView cells to include a switch in
each table item so that the user can “check” several choices/rows. It is
recommended that you follow a similar approach to that used for checkboxes in
Android lists viz. maintain a separate array including a Boolean variable to keep
track of the state of the switches. You can then display the results upon the click
of a button on your interface.
Hints: Change the switch state by clicking on the TableView cell rather than
clicking on the switch itself. Follow the example in Lecture 10 and create a new
class for the TableView cell. It is in this class that you would create an outlet for
the switch. In the ViewController you can create a function to loop through the
array referred to above using a decision to check if the Boolean variable
representing a switch in a cell is True.