안드로이드 세미나
DESCRIPTION
전 안드로이드 모릅니다TRANSCRIPT
ANDROID 세미나FOR BEGINNER (1)
PoolC 홍철주
2012. 3. 30
1
자바����������� ������������������ 개념..?
은����������� ������������������ 훼이크고코딩하는����������� ������������������ 법부터..
(C����������� ������������������ 언어와����������� ������������������ 비교를����������� ������������������ 위주로)
2
간단한����������� ������������������ 소스코드����������� ������������������ 분석
public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); }}
Hello, World!
3
기본����������� ������������������ 자료형����������� ������������������ 및����������� ������������������ 변수����������� ������������������ 선언
boolean b = true; char c = 'A'; int i = 1; float f = 1.0f; double d = 1.0; String s = "Hello, World!";
주로����������� ������������������ 쓰이는����������� ������������������ 기본����������� ������������������ 자료형
4
조건/반복문의����������� ������������������ 사용
if(/*condition*/) {} else if(/*condition*/) {} else {}
for(int i=0; i<3; i++) {}
switch(/*condition*/){ case true: break; case false: break; default:
} while(/*condition*/) {} do{}while(/*condition*/);
enhanced for*
5
배열����������� ������������������ 만들기
int[] a = new int[3];
new����������� ������������������ 키워드를����������� ������������������ 썼지만생성자*가����������� ������������������ 호출되지����������� ������������������ 않는다
6
클래스와����������� ������������������ 생성자Dog
개의����������� ������������������ 특징
이름����������� ������������������ :����������� ������������������ ����������� ������������������ (멍멍이)
나이����������� ������������������ :����������� ������������������ ����������� ������������������ (2살)
개의����������� ������������������ 행동
짖기
공격!
7
클래스와����������� ������������������ 생성자class Dog { private String name; private int age; public void bark() { System.out.println("bark!"); } public void attack() { System.out.println("attack!"); }}
개의����������� ������������������ 특징
개의����������� ������������������ 행동
ClassMember Variable
Member Function
8
일단����������� ������������������ 개를����������� ������������������ 키워보자
Dog d;d.attack();
FAIL
9
일단����������� ������������������ 개를����������� ������������������ 키워보자
Dog d = new Dog();d.attack();
GOOD
10
클래스와����������� ������������������ 생성자
class Dog {
...public Dog(){
}
... public void attack(){ System.out.println("attack!"); }}
생성자
11
다시����������� ������������������ 배열����������� ������������������ 초기화하기
Dog[] a = new Dog[3];
new����������� ������������������ 키워드를����������� ������������������ 썼지만생성자*가����������� ������������������ 호출되지����������� ������������������ 않는다
for(int i=0; i<a.length; i++) { a[i] = new Dog(); }
12
일단����������� ������������������ 여기까지
이후부터는����������� ������������������ 새로운����������� ������������������ 개념이����������� ������������������ 나오면����������� ������������������ 설명하기로..
13
안드로이드����������� ������������������ 개발환경����������� ������������������ 갖추기
Eclipse 다운받기
JDK 다운받기Android SDK 다운받기
긴����������� ������������������ 시간이����������� ������������������ 소요되므로����������� ������������������ 받아옵시다
14
안드로이드����������� ������������������ 앱����������� ������������������ 프로그래밍
여러����������� ������������������ 가지����������� ������������������ 객체와����������� ������������������ 함수
기본����������� ������������������ 레이아웃
Java를����������� ������������������ 차용했을����������� ������������������ 뿐,����������� ������������������ 그����������� ������������������ 이상����������� ������������������ 그����������� ������������������ 이하도����������� ������������������ 아님
레이아웃은����������� ������������������ xml을����������� ������������������ 이용
15
안드로이드����������� ������������������ 어플리케이션소스 구조
Source FilesDon’t TouchAndroid jar
Assets (Big Resources)binary, apk..Layout, String,...App Info
Eclipse config
16
안드로이드����������� ������������������ 시작하기Print Hello, World!
Click! ->
17
안드로이드����������� ������������������ 시작하기Print Hello, World!
그����������� ������������������ 전에디바이스를����������� ������������������ 사자가상����������� ������������������ 디바이스
(AVD)를����������� ������������������ 만들자!
18
안드로이드����������� ������������������ 시작하기Print Hello, World!
세미나 끝?
19
안드로이드����������� ������������������ 시작하기Print Hello, World!
R.layout.main?
AndroidTutorialActivity.java
20
안드로이드����������� ������������������ 시작하기Print Hello, World!
main은 어디에?
R.java
21
안드로이드����������� ������������������ 시작하기Print Hello, World!
main은 어디에?
R.javaes
res/drawableres/layout
res/string
22
안드로이드����������� ������������������ 시작하기Print Hello, World!
main은 여기에!
res/drawable
res/layout
23
안드로이드����������� ������������������ 시작하기Print Hello, World!
xml 문서도 배워야 하나?
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>
Layout
Text
24
안드로이드����������� ������������������ 시작하기Print Hello, World!
main.xml
LinearLayout
TextView
main.xml의����������� ������������������ 구조를����������� ������������������ 그리면����������� ������������������ 이렇게
25
안드로이드����������� ������������������ 시작하기Print Hello, World!
main.xml
LinearLayout
TextView
각����������� ������������������ 요소는����������� ������������������ 이미����������� ������������������ 정의되어����������� ������������������ 있다!
{ layout_width, heightorientation
{ layout_width, heighttext
http://developer.android.com/guide/topics/ui/declaring-layout.html
26
안드로이드����������� ������������������ 시작하기Print Hello, World!
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:id="@+id/hello" />
@����������� ������������������ &����������� ������������������ @+참조����������� ������������������ 및����������� ������������������ 등록을����������� ������������������ 할����������� ������������������ 때����������� ������������������ 사용!
string����������� ������������������ 요소들����������� ������������������ ->����������� ������������������ hello����������� ������������������ 참조id����������� ������������������ 요소들����������� ������������������ +����������� ������������������ hello
27
안드로이드����������� ������������������ 시작하기Print Hello, World!
<?xml version="1.0" encoding="utf-8"?><resources>
<string name="hello">Hello World, AndroidTutorialActivity!</string> <string name="app_name">AndroidTutorial</string>
</resources>Resources����������� ������������������ 요소에����������� ������������������ string����������� ������������������ 요소를
����������� ������������������ 넣어서����������� ������������������ 등록하면?
R.java에����������� ������������������ 등록이����������� ������������������ 된다!
28
안드로이드����������� ������������������ 앱����������� ������������������ 설정AndroidManifest
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="poolc.org" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".AndroidTutorialActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
</manifest>
29
안드로이드����������� ������������������ 앱����������� ������������������ 설정AndroidManifest
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="poolc.org" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".AndroidTutorialActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
</manifest>
30
NEXT SEMINAR?
• Analysis ComplexLayout.xml
• Activity? Intent? Context?
• Resources -> Source Code
• Simple Calculator
• Debugging, LogCat, Log, Toast
Maybe 4/6?
31
SIMPLE HOMEWORK
• Add 4 TextView elements.
• Each TextView has different color, size, text, style, id
올 ㅋ 올
(1)
(2)
32
Thank you
33