4. 事前準備
Android開發環境
– JDK
Download JDK (or from Oracle)
Installation and Environment Variable Settings
– JAVA_HOME
– PATH
– Installation result on cmd
– Android SDK and Studio
Download Android SDK and Studio (or from Android Developer)
Installation
– Launch the .exe file you just downloaded
– Follow the setup wizard
7. App Manifest
Manifest file
– The manifest file presents essential information about your app to the
Android system, information the system must have before it can run
any of the app's code.
Permission
– A basic Android application has no permissions associated with it by
default, meaning it cannot do anything that would adversely impact
the user experience or any data on the device.
– To make use of protected features of the device, you must include in
your AndroidManifest.xml one or more <uses-permission> tags
declaring the permissions that your application needs.
12. Dimens
Suggestions
– Because it's important that you design and implement your layouts for
multiple densities, the guidelines below and throught the
documentation refer to layout dimensions with dp measurements
instead of pixels.
– Similarly, you should prefer the sp (scale-independent pixel) to define
text sizes. The sp scale factor depends on a user setting and the system
scales the size the same as it does for dp.
14. 控制項
View class
– This class represents the basic
building block for user interface
components.
ViewGroup class
– The ViewGroup subclass is the base
class for layouts, which are invisible
containers that hold other Views (or
other ViewGroups) and define their
layout properties.
15. 控制項
View class
– This class represents the basic
building block for user interface
components.
ViewGroup class
– The ViewGroup subclass is the base
class for layouts, which are invisible
containers that hold other Views (or
other ViewGroups) and define their
layout properties.
16. TextView and EditText
TextView
– Displays text to the user and
optionally allows them to edit
it.
EditText
– EditText is a thin veneer over
TextView that configures itself
to be editable.
17. TextView and EditText
TextView
– Displays text to the user and
optionally allows them to edit
it.
EditText
– EditText is a thin veneer over
TextView that configures itself
to be editable.
18. LinearLayout
android:orientation -
setOrientation(int)
– Should the layout be a column
or a row? Use "horizontal" for a
row, "vertical" for a column.
android:gravity -
setGravity(int)
– Specifies how an object should
position its content, on both
the X and Y axes, within its own
bounds.
21. RelativeLayout
android:layout_above, android:layout_below
– Positions the bottom edge of this view above or below the given anchor view ID.
android:layout_alignParentBottom, android:layout_alignParentLeft,
android:layout_alignParentRight, android:layout_alignParentTop
– If true, makes the edge of this view match the edge you assign of the parent.
android:layout_toLeftOf, android:layout_toRightOf
– Positions the right edge of this view to the left or right of the given anchor view
ID.
android:layout_centerInParent
– If true, centers this child horizontally and vertically within its parent.
23. Event Listeners
Event Listeners
– An event listener is an interface in the View class that contains a single
callback method. These methods will be called by the Android
framework when the View to which the listener has been registered is
triggered by user interaction with the item in the UI.
– Included in the event listener interfaces are the following callback
methods:
onClick()
onTouch()
onLongClick()
onFocusChange()
onKey()