Purpose: This lab is designed to give you practice:
Using Android Studio Writing Java code to Handle UI events
Using an Android emulator Writing Java code to save and restore
Creating UI widgets using the designer the state of an Activity
and declaratively using AXML
Part 1: Do the textbook exercises shown below:
• 2-1, Create a Hello World app and modify it according to the instructions in the textbook.
• 2-2, Create the Invoice Total app UI.
Note: Use the Empty Activity template, set the min API to 11 or higher.
• 3-1, Finish the Invoice Total app.
Note: that for exercise 3-1, there is a starter project in the source code provided by the publisher of the textbook. It is identical to the finished version of 2-2, so you can just use your completed exercise 2-2 instead of the starter project.
Upload a text file to Canvas in which you will report, for each exercise above, whether you:
A. Followed all the steps shown in the book and successfully compiled and ran the program (where applicable).
B. Loaded the completed solution, experimented with the code, and ran the program (where applicable).
C. Read through the steps and inspected the relevant code listings without writing or running a program.
D. Didn’t do any of the above.
Part 2: Create an app that counts the number of times a button is clicked and that has a button that lets the user reset the count back to zero.
1. Create a new Android app using the Empty Activity template.
2. Using the existing RelativeLayout, add two buttons and an additional TextView to the XML file.
• Set one Button’s text to “Add One”, and give it an appropriate id
• Set the other Button’s text to “Reset”, and give it an appropriate id
• Give the existing TextView an appropriate id (it will be used to display the count)
• Set the new TextView’s text property to “Count” (it will be used as a label for the other TextView)
3. Write the event handlers for the application. One of the event handlers will contain code to increment a count and display it. The other will contain code to reset the count back to zero and display it.
• Add code to get references for the buttons and “Count” TextView
• Implement the event handlers and set them to the appropriate widgets
4. Optional, extra credit. Figure out how to store and retrieve the count so that it isn’t lost when the screen is rotated.
Zip the folder containing your project and upload it to Canvas.