Flag Quiz App 1 CS 7030 Mobile App

Flag Quiz App 1 CS 7030: Mobile App Development

assets Folder § drawable folder § Image contents at the root level assets folder – – – § Asset. Manager open an Input. Stream to read image file name; next create a Drawable object from the stream; finally display the object on an Image. View using set. Image. Drawable method – 2 Images can be organized in subfolders Accessed via Asset. Manager Input. Stream stream = assets. open(region + "/“ + next. Image. Name +". png"); Drawable flag = Drawable. create. From. Stream(stream, next. Image. Name); flag. Image. View. set. Image. Drawable(flag); CS 7030: Mobile App Development

String Resource § § 3 strings. xml – Create string array – <string-array name="regions. List"> <item>Africa</item> <item>Asia</item> <item>Europe</item> <item>North_America</item> <item>Oceania</item> <item>South_America</item> </string-array> get. Resources(). get. String. Array(R. array. regions. List); CS 7030: Mobile App Development

Animation Category Tweened Animations 1. – – 2. § 4 Scale animations (resize) Rotate animations Alpha animations (transparency) Translate animations (move) Frame-by-Frame Animations An animation set may contain any combination of tweened animations CS 7030: Mobile App Development

Animation xml file <set mlns: android="http: //schemas. android. com/apk/res/android" android: interpolator="@android: anim/decelerate_interpolator"> <translate android: from. XDelta="0" android: to. XDelta="-5%p" android: duration="100"/> <translate android: from. XDelta="-5%p" android: to. XDelta="5%p" android: duration="100" android: start. Offset="100"/> <translate android: from. XDelta="5%p" android: to. XDelta="-5%p" android: duration="100" android: start. Offset="200"/> </set> 5 CS 7030: Mobile App Development

Attributes of Animations § from. XDelta: the view’s offset when the animation starts to. XDelta: the view’s offset when the animation ends § These attributes can have § – – – § § 6 Absolute values (in pixels) A percentage of the animated View’s size A percentage of the animated View’s parent’s size -5%p indicates the View move to the left by 5% of the parent’s width 5% indicates the View move to the right by 5% of the View’s width duration: how long the animation lasts in milliseconds start. Offset: the number of milliseconds into the future at which an animation should begin CS 7030: Mobile App Development

Load Tweened Animations § § Create a folder called anim under res folder Create new xml files in the anim folder. Add a set tag in the xml files: <set xmlns: android="http: //schemas. android. com/apk/res/android" android: interpolator="@android: anim/decelerate_interpolator"> </set> § Add rotate, alpha, scale, or translate tag in the set tag. § Use Animation. Utils. load. Animation to load the xml file, and then create an object of Animation – § start. Animation – 7 shake. Animation = Animation. Utils. load. Animation(this, R. anim. incorrect_shake); flag. Image. View. start. Animation(shake. Animation); CS 7030: Mobile App Development

Handler § post. Delayed receives Runnable as arguments to execute and a delay in milliseconds § Each Handler instance is associated with a single thread and that thread's message queue. There are two main uses for a Handler: § – – 8 to schedule messages and runnables to be executed as some point in the future to enqueue an action to be performed on a different thread than your own. CS 7030: Mobile App Development
- Slides: 8