android_learning:headfirst_android_development_notes:chapter_2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
android_learning:headfirst_android_development_notes:chapter_2 [2016/01/06 06:06] – [p. 43] mithat | android_learning:headfirst_android_development_notes:chapter_2 [2016/01/07 04:45] (current) – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <WRAP center round important 60%> | ||
- | Under development. | ||
- | </ | ||
- | |||
====== Chapter 2 notes ====== | ====== Chapter 2 notes ====== | ||
===== About XML ===== | ===== About XML ===== | ||
- | In the previous chapter, we pretty much punted our way through the XML parts of a basic Android Project. We’ll use Android’s XML configuration files to a greater extent in this and subsequent chapters. You don’t need to be an XML expert to write the XML parts of an Android project; but you do need basic XML knowledge. | + | In the previous chapter, we pretty much punted our way through the XML parts of a basic Android Project. We’ll use Android’s XML configuration files to a greater extent in this and subsequent chapters. You don’t need to be an XML expert to write the XML parts of an Android project, but you do need basic XML knowledge. |
If you are brand new to XML and want a crash course in it, here are some resources for you to look into: | If you are brand new to XML and want a crash course in it, here are some resources for you to look into: | ||
- | * W3School’s [[http:// | + | * W3School’s [[http:// |
* A reasonable tutorial (video) by Mark Lassof: | * A reasonable tutorial (video) by Mark Lassof: | ||
{{youtube> | {{youtube> | ||
+ | \\ | ||
- | It might help you to know that XML was originally developed for use with Web technologies. It has since been adopted for use in many different situations. It’s | + | It might help you to know that XML was originally developed for use with Web technologies |
===== p. 42 ===== | ===== p. 42 ===== | ||
Line 31: | Line 28: | ||
===== p. 45: Some notes on Views ===== | ===== p. 45: Some notes on Views ===== | ||
- | **View**s are what Android calls the UI widgets that make up an Android user interface. All views inherit from a **View** superclass. | + | **View**s are what Android calls the UI widgets that make up an Android user interface. All views inherit from a View superclass. Button and TextView are two examples of Views. |
- | You specify the initial properties for Views in a **content_{whatever}.xml** layout file. You can add Views to a layout using Android Studio’s GUI builder or by manually writing the XML code. | + | You specify the initial properties for Views in a '' |
- | If you add a View to the layout using Android Studio’s GUI builder, Android Studio will give each View a unique name with the **android: | + | If you add a View to the layout using Android Studio’s GUI builder, Android Studio will give each View a unique name with the **android: |
<WRAP center round tip 100%> | <WRAP center round tip 100%> | ||
- | The first thing you should do when adding a new View to a layout is to change its name to something semantically useful! | + | //The first thing you should do when adding a new View to a layout is to change its name to something semantically useful!// |
- | If you don’t, you (or your boss, coworker, or instructor) will experience tremendous agony as you try to remember whether the button you want to use is called | + | If you don’t, you (or your boss, coworker, or instructor) will experience tremendous agony as you try to remember whether the button you want to use is '' |
</ | </ | ||
- | Notice that the text attribute for the button you added using the GUI builder was given as a string literal (android: | + | Notice that the text attribute for the button you added using the GUI builder was given as a string literal ('' |
===== p. 48: Code block ===== | ===== p. 48: Code block ===== | ||
Line 107: | Line 104: | ||
</ | </ | ||
- | ===== Codecheck 1 ===== | + | ===== p. 56: Codecheck 1 ===== |
The app through p. 56. | The app through p. 56. | ||
{{youtube> | {{youtube> | ||
+ | \\ | ||
+ | |||
+ | ===== p. 57: Code block ===== | ||
+ | Code from p. 57 is reproduced here to make it easy for you to copy/paste it into your project: | ||
+ | <code java> | ||
+ | package com.hfad.beeradviser; | ||
+ | import android.os.Bundle; | ||
+ | import android.app.Activity; | ||
+ | public class FindBeerActivity extends Activity { | ||
+ | @Override | ||
+ | protected void onCreate(Bundle savedInstanceState) { | ||
+ | super.onCreate(savedInstanceState); | ||
+ | setContentView(R.layout.activity_find_beer); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== p. 59 ===== | ||
+ | <code java> | ||
+ | Why do you have to cast the reference returned by '' | ||
+ | |||
+ | ===== pp. 60-62 ===== | ||
+ | <code java> | ||
+ | Why do you need to convert the value returned by '' | ||
+ | |||
+ | ===== p. 65: Codecheck 2 ===== | ||
+ | The app through p. 65. | ||
+ | {{youtube> | ||
+ | \\ | ||
+ | |||
+ | ===== p. 66: Quicktip ===== | ||
+ | Creating a new class in Android Studio | ||
+ | {{youtube> | ||
+ | \\ | ||
+ | |||
+ | ===== p. 66: Code block ===== | ||
+ | Code from p. 66 is reproduced here to make it easy for you to copy/paste it into your project: | ||
+ | <code java> | ||
+ | package com.hfad.beeradviser; | ||
+ | import java.util.ArrayList; | ||
+ | import java.util.List; | ||
+ | |||
+ | public class BeerExpert { | ||
+ | List< | ||
+ | List< | ||
+ | if (color.equals(" | ||
+ | brands.add(" | ||
+ | brands.add(" | ||
+ | } else { | ||
+ | brands.add(" | ||
+ | brands.add(" | ||
+ | } | ||
+ | return brands; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== p. 69 ===== | ||
+ | The [[http:// | ||
+ | |||
+ | ===== p. 71: Finished ===== | ||
+ | {{youtube> | ||
+ | \\ | ||
android_learning/headfirst_android_development_notes/chapter_2.1452060382.txt.gz · Last modified: 2016/01/06 06:06 by mithat