Title: ??????? IT ??
1????? ????????
??????? IT ?? ??? ??
2???? ???????? ??
3???? ??
4???? ??
5????? ??
??
6????? ??
7???? ??, ??? ??
8???? ??? ?? ?? ??
9???? ?? ??
- ????? ??????? ??
- ??? ????? ?? ??? ?? ??? ??? ???
- ?? ??? ?? /src? /gen
- ??? ??? ?? /drawable, /layout, /values, /assets
- XML, PNG, JPEG ?? ??? ??? ??? ??? ??
- ????? ?????
- Androidmanifest.xml
10???? ?? ??
- src/ ??? Hell1.java ?? ??
11???? ?? ??
12???? ?? ??
- ???
- res/ ??
- ??? ??(/drawable)
- jpg, png ?? ?? ??? ??
- ?? ?????? ??????? ???? icon.png? ??
- ???? ????? ?? ?? ??? ??? ??? ??? ??
- ?? ??? ?? ??? ? ?? ??? ????(a-z0-9_.)? ??
- ???(????, ????, ????)? ?? ?? ???? ??
13???? ?? ??
- ???
- ????(/layout)
- ??????? ??? ???? ???? ???? ??
- ????? ????? main.xml ??? ??
14???? ?? ??
- ???
- ?? ?? ?? ?(/values)
- ???, ?? ? ?? ???????? ???? ?? ?? ??? ??
- ?? ?????? ???? ???? strings.xml ??? ??
15???? ?? ??
- ????? ??(AndroidManifest.xml)
- ??????? ???? ?? ??
- ??????? ??? ??, ????(????, ??? ?) ??, ?? ??,
???? ????? ? ??????? ??? ???? ??? ??
16?????? ??
17???? ?? ??
18???? ?? ??
package com.corea.Hello1 import
android.app.Activity import android.os.Bundle p
ublic class Hello1 extends Activity /
Called when the activity is first created. /
_at_Override public void onCreate(Bundle
savedInstanceState) super.onCreate(saved
InstanceState) setContentView(R.layout.ma
in)
include ltstdio.hgt int main() printf(Hello
World, Hello1!\n) return 0
19???? ?? ??
- import android.app.Activity
- Activity? ?? ?????? ??? ??? ???? ??
- Activity? ??? ????? ????? ??? ???? ????? ???? ???
?? - ?????? ??? Activity? ??
- import android.os.Bundle
- Bundle? ???? ??? ??? ??(?? ??, toString,
getString, getShort ?)? ???? ??? - C ??? stdio.h? ???
20???? ?? ??
- onCreate(Bundle savedInstanceState)
- ????? ??? ? ??
- ????? UI? ???? ?? setContentView()? ?? ???? ??
- Bundle ??? ??????? ??/??? ?? ?? ??? ???? ??
- setContentView(R.layout.main)
- R ???? ?? ???? layout ???? main ??? ??? ??
- R.java ??? ???? ?? ?? ?? ??? ??? ??? ??
21???? ?? ??
package com.corea.Hello1 public final class R
public static final class attr
public static final class drawable
public static final int icon0x7f020000
public static final class layout
public static final int main0x7f030000
public static final class string
public static final int app_name0x7f040001
public static final int hello0x7f040000
R ???? ?? ???? ??? ? ?? ??? ??? ?? ? ?? ??
22???? ?? ??
- ????
- ?(view)? ?? ??? UI? ???? ?? ????. ?? ?? ???, ???,
??, ?? ?? ?? ???? ?? ?? ?? - ????(layout)? ? ?? ?? ?? ???? ???? ??? ???(View
Group) - ????? ????? XML? ??. ???? ?? ??
lt?xml version"1.0" encoding"utf-8"?gt ltLinearLayo
ut xmlnsandroid"http//schemas.android.com/apk/r
es/android" androidorientation"vertical"
androidlayout_width"fill_parent"
androidlayout_height"fill_parent"
gt ltTextView androidlayout_width"fill_paren
t" androidlayout_height"wrap_content"
androidtext"_at_string/hello"
/gt lt/LinearLayoutgt
????? ????
????, ? ??? ??? ??? ?? ??
?? ??? ?? ??
?? ?? ??? ? ?? ??? ??? ??
23???? ?? ??
lt?xml version"1.0" encoding"utf-8"?gt ltresourcesgt
ltstring name"hello"gtHello World,
Hello1!lt/stringgt ltstring name"app_name"gtHello
1 Demolt/stringgt lt/resourcesgt
24???? ?? ??
lt?xml version"1.0" encoding"utf-8"?gt ltmanifest
xmlnsandroid"http//schemas.android.com/apk/res/
android" package"com.corea.Android
androidversionCode"1" androidversionName
"1.0"gt ltapplication androidicon"_at_drawable/ic
on" androidlabel"_at_string/app_name"gt
ltactivity androidname".Android"
androidlabel"_at_string/app_name"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
ltcategory androidname"android.intent.
category.LAUNCHER" /gt
lt/intent-filtergt lt/activitygt
lt/applicationgt ltuses-sdk androidminSdkVersion
"7" /gt lt/manifestgt
? ??? ??
? ?????? ??
? ??? ?? ??
25???? ?? ??
- AndroidMenifest.xml
- ????? ??? ?????? ??????? ??? ? ??? ?? ?? ?
????, ????? ? ??, ??? ? ? ?? - ?? _at_? ??? ???? ??? ? ?? ??? ??
- Android ??????? ??? ????? ??
- ??? ??? ????, ???, ?????? ???? ??? ? ?? ???? ???
?? - android.intent.action.MAIN? ??????? ???(entry
point)? ?? - android.intent.category.LAUNCHER? ?????
??(launcher)? ?? - android.intent.action.MAIN? android.intent.categor
y.LAUNCHER? ??? ?? ????? ?????? ?? ? ??? ???
????? ??
26???? ?? ??
27??? ??? ????
28???? ?? ??
- ???? ??
- ? ?? ????? ??? ???? Hello2Demo ????? ??
- ??? ??
- ??? ??? ???? R.java? ???? ??
- ???? ??? ??? ?????? ???? ??
29???? ?? ??
30???? ?? ??
- ???? ??? import ?? ??
- ctrl shift o
31???? ?? ??
32???? ?? ??
package com.corea.Android import
android.app.Activity import android.os.Bundle im
port android.widget.TextView public class
Android extends Activity / Called when
the activity is first created. / _at_Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState)
TextView hello new TextView(this)
hello.setText("Hello World, Android!")
setContentView(hello)
33???? ?? ??
- TextView
- ??? ???? ???? ??
- ???
- TextView(this)?? this? Activity
- Activity ???? ???
Public TextView(Context context) Public
TextView(Context context, AttributeSet
attrs) Public TextView(Context context,
AttributeSet attrs, int defStyle)
Java.lang.Object android.content.Context
android.content.ContextWrapper
android.view.ContextThemeWrapper
android.app.Activity
34???? ?? ??
- setText()
- ??
- setContentView()
- ???? ?? ?(view)? activity? ???? ???? ??
- ??
- hello? TextView
- TextView? View? ?????
public void setText(CharSequence text) public
void setText(int resid)
public void setContentView(int layoutResID) public
void setContentView(View view)
35??? ?? ???? ??
36??? ??? ?? ???
- ???? ?? ??
- TextView ??? ??? ?? ??????
ltLinearLayout xmlnsandroid"http//schemas.androi
d.com/apk/res/android" androidorientation"ve
rtical" androidlayout_width"fill_parent"
androidlayout_height"fill_parent"
androidbackground"ffffffffgt ltTextView
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidtext"??" androidbackground"ffff000
0 /gt ltTextView androidlayout_width"wrap_c
ontent" androidlayout_height"100dp"
androidtext"??" androidtextColor"ff000000
" androidtextSize"50sp"
androidbackground"ff00ff00 /gt lt/LinearLayoutgt
37??? ??? ?? ???
- TextView ??? ??
- background
- textSize
- textColor
- textStyle
- gravity ? ???? ??? ??
- top, bottom, left, right
- center, center_vertical, center_horizontal
- fill, fill_vertivcal, fill_horizontal
- visibility
- visible
- invisible(? ??? ?? ??), gone(???? ?? ???? ??)
38??? ??? ?? ???
- ??
- ?? ?? ?? ? ??
- ?? ?? ??(???) ??? ?? 4?? ??
- RGB
- ARGB
- RRGGBB
- AARRGGBB
- ??? ?? ?? ??? ???
- ??
- ?? px
- ?? in
- ???? mm
- ??? pt
- ?? ?? ?? dp(density-independent pixel)
- ?? ?? ?? sp(scale-independent pixel)
1dp? 160dpi???? 1px? ??
39??? ??
40??? ??
lt?xml version"1.0" encoding"utf-8"?gt ltImageView
xmlnsandroid"http//schemas.android.com/apk/res/
android" androidid"_at_id/icon"
androidlayout_width"wrap_content"
androidlayout_height"wrap_content"
androidadjustViewBounds"true"
androidsrc"_at_drawable/wavelogo"/gt
lt?xml version"1.0" encoding"utf-8"?gt ltLinearLayo
ut xmlnsandroid"http//schemas.android.com/apk/r
es/android" androidorientation"vertical"
androidlayout_width"fill_parent"
androidlayout_height"fill_parentgt ltImageView
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidsrc"_at_drawable/wavelogo/gt lt/LinearLayoutgt
41??? ??
- ???? ?? ???
- drawable-hdpi, drawable-ldpi, drawable-mdpi
- ?? ???? ??
- ???? ??? ??
- png
- 9-patch
- jpg
- gif
42???? ??? ????