To Lecture Notes

IT 372 -- Apr 17, 2019

Review Questions

  1. How does an Android App know which startup activity file to use?
    Ans: The startup activity has these tags between <activity> and </activity>:
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
  2. Give the hex color codes for these colors:
        red      Ans: #ff0000
        green   Ans: #008000
        purple  Ans: #800080
        teal     Ans: #008080
        gray     Ans: #808080
        silver   Ans: #c0c0c0
  3. Trivia Question: Name three major universities whose names are colors.
    Hint: one of them is Navy.  Ans: There are actually three more: Brown, Siena, Auburn
  4. Show six ways of setting the background color in a layout.
    Hint: Use this chart of hex color codes if you get stuck.
    Ans: The first three ways are in the layout, the last three are in the Java activity file:
    1. android:background="@android:black"
    2. android:background="0xc0ffc0"
    3. android:background="@color/lightGreen
    4. layout.setBackground(getResource( ).getColor(Color.GREEN));
    5. layout.setBackground(getResource( ).getColor(Color.parseColor("0xc0ffc0"));
    6. layout.setBackground(getResource( ).getColor(R.color.lightGreen));
  5. Create an Android app with a button. When the button is pressed repeatedly, the background color of the linear layout cycles through three colors or your choice.
    Ans: See the ChangeColors Example.

Using Images

Multiactivity Apps and Intents