안드로이드 세미나

33
ANDROID 세미나 FOR BEGINNER (1) PoolC 홍철주 2012. 3. 30 1

Upload: chul-ju-hong

Post on 15-Jun-2015

402 views

Category:

Technology


0 download

DESCRIPTION

전 안드로이드 모릅니다

TRANSCRIPT

Page 1: 안드로이드 세미나

ANDROID 세미나FOR BEGINNER (1)

PoolC 홍철주

2012. 3. 30

1

Page 2: 안드로이드 세미나

자바����������� ������������������  개념..?

은����������� ������������������  훼이크고코딩하는����������� ������������������  법부터..

(C����������� ������������������  언어와����������� ������������������  비교를����������� ������������������  위주로)

2

Page 3: 안드로이드 세미나

간단한����������� ������������������  소스코드����������� ������������������  분석

public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); }}

Hello, World!

3

Page 4: 안드로이드 세미나

기본����������� ������������������  자료형����������� ������������������  및����������� ������������������  변수����������� ������������������  선언

boolean b = true; char c = 'A'; int i = 1; float f = 1.0f; double d = 1.0; String s = "Hello, World!";

주로����������� ������������������  쓰이는����������� ������������������  기본����������� ������������������  자료형

4

Page 5: 안드로이드 세미나

조건/반복문의����������� ������������������  사용

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

Page 6: 안드로이드 세미나

배열����������� ������������������  만들기

int[] a = new int[3];

new����������� ������������������  키워드를����������� ������������������  썼지만생성자*가����������� ������������������  호출되지����������� ������������������  않는다

6

Page 7: 안드로이드 세미나

클래스와����������� ������������������  생성자Dog

개의����������� ������������������  특징

이름����������� ������������������  :����������� ������������������  ����������� ������������������  (멍멍이)

나이����������� ������������������  :����������� ������������������  ����������� ������������������  (2살)

개의����������� ������������������  행동

짖기

공격!

7

Page 8: 안드로이드 세미나

클래스와����������� ������������������  생성자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

Page 9: 안드로이드 세미나

일단����������� ������������������  개를����������� ������������������  키워보자

Dog d;d.attack();

FAIL

9

Page 10: 안드로이드 세미나

일단����������� ������������������  개를����������� ������������������  키워보자

Dog d = new Dog();d.attack();

GOOD

10

Page 11: 안드로이드 세미나

클래스와����������� ������������������  생성자

class Dog {

...public Dog(){

}

... public void attack(){ System.out.println("attack!"); }}

생성자

11

Page 12: 안드로이드 세미나

다시����������� ������������������  배열����������� ������������������  초기화하기

Dog[] a = new Dog[3];

new����������� ������������������  키워드를����������� ������������������  썼지만생성자*가����������� ������������������  호출되지����������� ������������������  않는다

for(int i=0; i<a.length; i++) { a[i] = new Dog(); }

12

Page 13: 안드로이드 세미나

일단����������� ������������������  여기까지

이후부터는����������� ������������������  새로운����������� ������������������  개념이����������� ������������������  나오면����������� ������������������  설명하기로..

13

Page 14: 안드로이드 세미나

안드로이드����������� ������������������  개발환경����������� ������������������  갖추기

Eclipse 다운받기

JDK 다운받기Android SDK 다운받기

긴����������� ������������������  시간이����������� ������������������  소요되므로����������� ������������������  받아옵시다

14

Page 15: 안드로이드 세미나

안드로이드����������� ������������������  앱����������� ������������������  프로그래밍

여러����������� ������������������  가지����������� ������������������  객체와����������� ������������������  함수

기본����������� ������������������  레이아웃

Java를����������� ������������������  차용했을����������� ������������������  뿐,����������� ������������������  그����������� ������������������  이상����������� ������������������  그����������� ������������������  이하도����������� ������������������  아님

레이아웃은����������� ������������������  xml을����������� ������������������  이용

15

Page 16: 안드로이드 세미나

안드로이드����������� ������������������  어플리케이션소스 구조

Source FilesDon’t TouchAndroid jar

Assets (Big Resources)binary, apk..Layout, String,...App Info

Eclipse config

16

Page 17: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

Click! ->

17

Page 18: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

그����������� ������������������  전에디바이스를����������� ������������������  사자가상����������� ������������������  디바이스

(AVD)를����������� ������������������  만들자!

18

Page 19: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

세미나 끝?

19

Page 20: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

R.layout.main?

AndroidTutorialActivity.java

20

Page 21: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

main은 어디에?

R.java

21

Page 22: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

main은 어디에?

R.javaes

res/drawableres/layout

res/string

22

Page 23: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

main은 여기에!

res/drawable

res/layout

23

Page 24: 안드로이드 세미나

안드로이드����������� ������������������  시작하기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

Page 25: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

main.xml

LinearLayout

TextView

main.xml의����������� ������������������  구조를����������� ������������������  그리면����������� ������������������  이렇게

25

Page 26: 안드로이드 세미나

안드로이드����������� ������������������  시작하기Print Hello, World!

main.xml

LinearLayout

TextView

각����������� ������������������  요소는����������� ������������������  이미����������� ������������������  정의되어����������� ������������������  있다!

{ layout_width, heightorientation

{ layout_width, heighttext

http://developer.android.com/guide/topics/ui/declaring-layout.html

26

Page 27: 안드로이드 세미나

안드로이드����������� ������������������  시작하기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

Page 28: 안드로이드 세미나

안드로이드����������� ������������������  시작하기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

Page 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>

29

Page 30: 안드로이드 세미나

안드로이드����������� ������������������  앱����������� ������������������  설정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

Page 31: 안드로이드 세미나

NEXT SEMINAR?

• Analysis ComplexLayout.xml

• Activity? Intent? Context?

• Resources -> Source Code

• Simple Calculator

• Debugging, LogCat, Log, Toast

Maybe 4/6?

31

Page 32: 안드로이드 세미나

SIMPLE HOMEWORK

• Add 4 TextView elements.

• Each TextView has different color, size, text, style, id

올 ㅋ 올

(1)

(2)

32

Page 33: 안드로이드 세미나

Thank you

33