Difference between revisions of "MAP524/DPS924 Lab 4"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'Create a simple Android app, named FragmentExample that continues from the example given in this week's lecture. Once you have …')
(No difference)

Revision as of 22:09, 12 July 2015

Create a simple Android app, named FragmentExample that continues from the example given in this week's lecture.

Once you have the basic app running correctly from the notes, make these modifications:

  1. Change the background colour of each of the layout files to something more light and pleasing - not the dark red, green and blue (RGB) used in the original app.
  2. Change the two text views in each fragment layout to image views.
  3. Find two image (png) files and add them to the drawable directory of your app.
  4. Change each fragment layout to these images.
  5. At this point you should run your app. It should look something like this:

 

Frag1.png

 

  1. Notice that one image has a white background while the other has a transparent background.
  2. Also notice the background colours are a little nicer than in the original app (but come up with your own).
  3. Now change the text view in the main activity's layout to a button instead. Label the button Switch.
    • Note: the label on the button should be defined in the strings.xml file
  4. If you run your app now, you should see something like this:
  5.  

    Frag2.png

     

  6. Now add an onClick method to your main activity to handle the clicking of the button.
  7. When the button clicks, the images in each fragment should be exchanged to now look something like this:
  8.  

    Frag3.png

     

  9. Finally modify your code so that each time the button is clicked the images in the two fragments will be exchanges.
  10. Run your app and create your own screencast. You can do this in Linux Mint by turning on recording with these keystrokes - CTRL-SHIFT-ALT-R. You will see a red bullet on your window indicating recording is turned on.
    • Now click the button several times to show your app functions correctly.
    • To stop recording just hit CTRL-SHIFT-ALT-R a second time.
    • Your recording is saved in your home directory