CISC181 S2019 Lab7

From class_wiki
Revision as of 11:58, 24 April 2019 by Cer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


  • Make a new Android project with n = 7 with an Empty Activity following the instructions in the Apr. 23 lecture slides.


First, make the empty activity project as described above and confirm that you can build and run it -- either on the emulator or an actual Android device as explained on "Run Your App".

Second, take the empty activity project and modify it to become a very simple "rock paper scissors" generator as detailed below:

  1. Change the layout in activity_main.xml to a vertical LinearLayout, similar to this example
  2. Change the old TextView that was printing "Hello, world" to say "Click the button below to get a new shape".
  3. Add an ImageView underneath, centered laterally, that initially shows a rock, paper, OR scissors image. Find your own for these, cropped and scaled to 250 x 250, and put them in res/drawable with the names "rock.png", "paper.png", and "scissors.png". Here's some help for drawable resources
  4. Add a TextView underneath the image which acts as a caption, saying "Rock" if the image is a rock, "Paper" if it's paper, and "Scissors" if it's scissors. The caption should be centered laterally.
  5. Finally, add a centered Button under the caption. This button should be labeled "New" and when pressed causes another random selection which (possibly) changes the image and caption above . The caption text should be set not through resources but instead by using setText() in, and something similar should be done with the image.

Note: Do NOT make changes to any other XML resource file besides activity_main.xml.

Here is a screenshot of a sample program that satisfies the above requirements (except it should say "MyLab_7"):



Submit your and activity_main.xml. Make sure your name is in both. FYI, comments in XML files look like this:

<!-- here is my name -->