本次澳洲作业案例主要为Practical Exercise相关的APP
Task 0 – Self-Exploration
Review the Week 4 “Content Slides” about the “Mobile Ecosystem”. Write down how you would answer the following question:
“What is the mobile ecosystem ” (100-200 words).
Objective: Construct the Reflex Checker App
Let us imagine that you are a HCI researcher trying to understand how humans respond to mobile user interfaces that scroll vertically. You imagine an App that tests “interactivity speed” by asking a user to complete randomly generated “checkbox selection tasks” as quickly as possible. You are doing this because you want to find out if age is important factor behind interactivity speed.
You decide that your App will use a set of randomly chosen names of drinks and fruits. You want the App to randomly ask the user three different tasks: 1) select all items, 2) deselect all items, 3) select one item. You also add in randomly selected images to spare out the check boxes. Here is an example of what the final App could look like:
Task 1 – Setup the project – FrameLayout, resources, formatting
1. Create a new “Empty Activity” Android Studio project called ReflexChecker. Setup its package name as au.edu.jcu.cp3406.reflexchecker. Set the API level at 19. Be careful to check the folder location since Android Studio remembers the previous folder location
2. Adjust the MainActivity’s layout as follows:
a. Replace the ConstraintLayout with a FrameLayout
b. Adjust its TextView as follows: remove unnecessary constraint attributes, set its margins to be 16dp, layout_width matching its parent, layout_height wrapping its content and add the following text directly to its text attribute:
Android Studio should tell you that directly adding text like this is not “best practice”
3. So “extract string resource” and move the text into strings.xml. Name this new string resource “instructions”.
After extracting, your TextView should look like this:
4. Next, add the “Start” Button to the center of the FrameLayout – use layout_gravity to do this!
Make use of another string resource for its text.
5. Add an onClick attribute to the “Start” Button for a new Java method called “startTest”. Create the necessary Java method in your MainActivity.
6. Add a new “empty activity” to your project called GameActivity. Add the necessary Java code to startTest() to create an explicit intent that starts your GameActivity.
In Android Studio, it is a good idea to regularly use CTRL-ALT-L and CTRL-ALT-O after you edit XML or Java code. CTRL-ALT-L is the keyboard shortcut for “reformat code”. CTRL-ALT-O is the keyboard shortcut for “optimize imports”. Note that these are also available under the “Code” menu in Android Studio.
You should regularly check your XML for formatting and/or import issues!
7. Test out your work and make sure the Start Button takes you from the MainActivity to the GameActivity.