Algorithms and OOD (CSC 207 2013F) : Labs
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
In this laboratory you will practice adding and using resources, and giving your app a very simple functionality.
Make sure you've completed and understood the reading, Making Our Apps Do Things. You probably want to keep it up in a separate tab.
Create a new android project. Name it “Meowing Kitty”. Follow one of the package naming conventions we've discussed in previous readings.
a. Grab your favoirte picture of a cat or kitten.
b. Download your favourite meowing noise here: http://soundbible.com/tags-kitten.html
. Make sure to
Download the mp3 version
a. You should already know where to put your image file, but make sure to rename it if it uses capital letters or special characters
b. To add a sound to your resources, you have to make a new folder called "raw"
c. Now drag your sound file to the folder, and rename it if neccessary
a. Add your picture and a button to your application
b. Feel free to use whatever layout you prefer, but give your layout elements the appropriate attributes and make sure you create the neccessary Strings to accompany them
c. Using the second method we discussed in the reading for adding functionality to a layout element, connect you button to a method that displays a simple "Meow" message to the user when clicked
a) As you did with the button, add an attribute to your ImageView that defines what happens when it's clicked
b. The process of having a method play a sound, is very similar to the one of creating our simple message
Replace the Toast object with a MediaPlayer. You'll need to import that class, or Eclipse will be upset.
c. The method to call instead of makeText
is
create
, and its parameters are Context and
the resource ID of the sound file
d. If you've forgotten how to get the resource ID of a file in the res folder, remember the R class (you need to omit the .mp3 part when refering to the file's name)
e. We can't really “show()” a MediaPlayer, but we can “start()” it
a. Save all the files, compile and run the app
b. If it fails, talk to your mentor or instructor
Find a way to make the cat stop miaowing.
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Copyright (c) 2013 Samuel A. Rebelsky.
This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.