Lesson 1: Create Project Sunshine

Udacity – Developing Android Apps

Lesson 1 notes:

  • Target SDK vs minimum SDK. The Target SDK. An example is that if there is a new feature recently introduced but not critical to the application, the target SDK should set to the version which the new feature was released in but have the minimum SDK to a lower version that your application is still functional without the new feature.
  • Layout Design
    • Frame Layout – useful for simple layouts with a single view or stack or views. Views are all aligned against the frame boundaries only.
    • Linear Layout – perfect for stacking views vertically or horizontally, one after another. Proportionally break up the screen.
    • Relative Layout – allow the positioning of view relative to other views or the boundaries of the view.
  • Add ListItem XML
    • create new layout resource file
    • in text view, define width, height, minHeight, gravity and id.
  • Add ListView to layout
    • at fragment_main, create ListView and define width, height, id
    • for “match_parent”, check the parent tag and the tag in activity_main to verify dimension (width & height).
  • Create Fake Data
    • create an array of string and then create an ArrayList of string to contain those string data.
  • Initialize ArrayAdapter Parameters
    • Context – contain global information of the app environment, allow access to system services and resources, and application specific resources. getActivity().
    • ID of list item layout – using this as a reference to the XML layout to get the layout for each list item. R.java class create human readable identifiers for resources. (R.layout refer to a specific layout file)
    • ID of text view – using this as a reference the text view that know how to display a string for a text view (R.id is refer to a specific XML element with the matching id attribute.)
    • list of data – the data to be display in the text view of the specific layout.
  • Binding ListView
    • system takes an inflated XML layout and turn it into full view hierarchy. root layout is the main_Activity.
    • to get a reference to an object, use findViewById to traverse through the hierarchy until it find the object
    • using subtree root reference as a starting location for searching child’s object.