Download presentation
Presentation is loading. Please wait.
Published byEustacia Lester Modified over 8 years ago
1
Flag Quiz Game App Android How to Program ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
3
Test drive app Quiz progress Current Flag Answer options
4
©1992-2013 by Pearson Education, Inc. All Rights Reserved.
10
#000000 #FFFFCC #00CC00 #FF0000
11
©1992-2013 by Pearson Education, Inc. All Rights Reserved.
16
The answer Buttons will be dynamically added. NOTE: There are 3 rows, but two of them may be left empty.
17
©1992-2013 by Pearson Education, Inc. All Rights Reserved.
18
The answer Buttons ©1992-2013 by Pearson Education, Inc. All Rights Reserved. When you answer, “What type of resource…?” Select as the root element Button.
19
Creating Shake Animation Defined in an.xml file (SURPRISE!) Right click the layout folder, select New > Other In the Android node, select Android XML file, click Next> to display the New Android XML File In the File text field enter the name incorrect_shake.xml Under “What type of resource….?”, select the Animation radio button. ▫ Puts the new file into the project’s res/anim folder At bottom of dialog, select set as the animation’s root element Click finish Configure properties ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
20
3 translate animations in this animation set Animation set may contain Any combination of tweened animations: Alpha (transparency) Scale Translate (moves a view within parent) rotate fromXDelta is View’s offset when animation starts toXDelta is offset when It ends How long animation last in milliseconds So animations don’t run in parallel
21
Technologies Overview Using App’s Assets Folder ▫ Can drag folders of images to here ▫ Must be accessed via AssetManager to open InputStream to read file Using Menu ▫ Override Activity’s onCreateOptionsMenu ▫ onOptionsItemSelected is the event handler method that responds to user’s selection Using Runnable ▫ Use a Handler object to execute Runnable to delay displaying next flag ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
22
Technologies Overview Applying Animation to an ImageView ▫ Use AnimationUtils static method loadAnimation to load animation from.xml file ▫ Specify # times animation should repeat with method setRepeatCount ▫ Call startAnimation to perform the animation Logging Exception Messages ▫ For debugging purposes ▫ Use try/catch blocks when processing files ▫ Can view logged messages with Android logcat tool. ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
23
Using ArrayList Import package for this templated data structure Expandable “array” Can access like an array, has methods, process with for each loop private List list; list = new ArrayList (); int numItems = list.size(); list[i] = myString; myString = list.get(index); for (String s : list) //use s somehow; can’t change it if (s.equals(keyString)) count++; list.add(anotherString); list.remove (index); or list.remove(theString); list.clear(); Collections.shuffle (list); ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
24
Also a HashMap Using HashMap ▫ To store region names and corresponding Boolean values to indicate if region is enable or not ▫ Has methods we’ll see ▫ Can be processed with a for each loop We are using ArrayList and HashMap objects, but their references are of type List and Map, resp. ▫ Good Java practice, so we can change data structures easily without affecting rest of app’s code Also using interface Set when we want all keys in the HashMap ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
25
Building the FlagQuizGame App ©1992-2013 by Pearson Education, Inc. All Rights Reserved. Data Structures Error logging Folders of images
26
©1992-2013 by Pearson Education, Inc. All Rights Reserved.
48
AndroidManifest File New Features android:theme attribute ▫ A theme is a set of styles that specify the appearance of a GUI’s components ▫ List of predefined styles and themes on the web android:screenOrientation ▫ The FlagQuizGame app should always be in portrait mode ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
49
AndroidManifest Editor /Application Tab ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
50
AndroidManifest File ©1992-2013 by Pearson Education, Inc. All Rights Reserved.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.