<BFF8B5E5B7CEC0CCB5E5322E687770>

Size: px
Start display at page:

Download "<BFF8B5E5B7CEC0CCB5E5322E687770>"

Transcription

1 안드로이드응용프로그램개발 호서대학교뉴미디어학과이호석교수

2 알림 [1] 세미나자료의 1 장부터 11 장에있는안드로이드관련내용과안드로이드소스코드는참고문헌 (1)(2)(3) 에서발췌하여작성하였다. 12 장과 13 장의내용은 developer.android.com 을참고하여작성하였으며소스코드는 (2)(3) 에서발췌하여작성하였다. [2] 안드로이드에대한최신의내용은 developer.android.com 바란다. 을참고하기 [3] 국내의관련웹으로는 o.kr 이있다.

3 목차 1 장. 안드로이드소개 장. 안드로이드개발환경과기본프로그래밍방법 장. 안드로이드응용프로그램개발 장. 기본위젯예제프로그램 장. 레이아웃을이용한사용자인터페이스설계 장. 선택기능위젯 장. 리스트고급활용 장. 고급위젯과컨테이너 장. 메뉴 장. WebKit 장. 화면회전 장. 그래픽과애니메이션 장. 위치기반서비스

4 1 장. 안드로이드소개 - OHA(Open Handset Alliance, 핸드폰개발과판매에대한관련개발업체들의연합 (2007 년말결성) ( 칩제조사, 단말기제조사, 소프트웨어개발사, 서비스공급업체, 예를들어 Intel, Qualcomm, Samsung, LG, Google, HTC, NVIDIA, Microso ft, Motorola, Texas Instrument, China Mobile 등). 비독점개방형표준플랫폼공동개발 -> 안드로이드 - 안드로이드시스템. 안드로이드시스템설치. J2SE, Eclipse, Android SDK, Android DT+DDMS Plug-in, Pref erence setting. 안드로이드라이브러리. android.util: 코어유틸리티패키지로서컨테이너, 문자열포맷터, XML 파싱등제공. android.os: 메시지전달, 프로세스통신, 시계기능, 디버깅기능제공. android.graphics: Canvas, 색상, drawing primitives 등기본그래픽환경제공. android.text:. android.database:. android.content: 텍스트출력과파싱을위한텍스트처리도구 데이터베이스커서기능제공 콘텐트공급자기능제공. android.app.activity: 모든안드로이드애플리케이션을위한 Activity 클래스를포함.. android.view.view: Activity 와함께가장핵심적인클래스, 모든화면출력은 View 상속. android.widget: 윈도우콤포넌트이다. 버튼, 리스트, 체크박스등등. com.google.android.maps: 지도기능을제공한다. 위치기반서비스, MapView 등,. android.provider: 표준콘텐츠공급자에쉽게접근하는클래스제공.. android.telephony: 전화, 전화상태, SMS 메시지기능을제공한다.. android.webkit:. android.location:. android.media: 안드로이드웹브라우저 위치기반서비스제공 멀티미디어클래스제공. android.opengl: OpenGL ES 그래픽 API 제공. android.hardware: 카메라, 가속도센서, 나침반센서. android.bluetooth: 불루투스통신기능제공. android.net.wifi: WiFi 통신기능제공 - 1 -

5

6 . C/C++ 라이브러리. OpenGL ES: OpenGL ES 1.0 API 3D 그래픽스제공 (OpenGL ES v2.0). FreeType: 비트맵, 벡터폰트렌더링. SGL: 2D 그래픽엔진. libc: 리눅스기반임베디드장치에최적화된표준 C 라이브러리. SQLite: 관계형데이터베이스. SSL: Secure Socket Layer 암호프로토콜. 안드로이드소프트웨어구성. Activity. View: 윈도우위젯(Widget), 레이아웃(Layout). 보안네트워킹(SSL). 웹브라우저(WebKit). 네트워킹 API. SQLite 데이터베이스. OpenGL ES 3 차원그래픽. 멀티디어 API: 정지영상, MPEG4, MP3. 전화걸기 & SMS 보내기 API. LBS(Location-Based Service, 위치기반서비스) API:. 센서 API: 온도, 가속도등. 통신 API: WiFi, Bluetooth 지도서비스. 안드로이드애플리케이션아키텍처. Activity: 사용자기본윈도우( 핸드폰화면).. View: 윈도우에설치되는모든 UI 구성요소( 위젯, 레이아웃).. Intent: 원하는기능(action, message, 전화걸기등). Notification: 사용자에게신호를보내는기능, 예를들어전화가걸려왔을때불빛을 깜박이거나, 진동을울리거나, 아이콘표시를하거나, 등등.. Broadcast Receiver: Broadcasting되는 Intent 를처리한다.. Content Provider: 응용을간의데이터공유를위한인터페이스, SharedPreferences.. Service: 백그라운드모드로항상동작하는기본구성요소.. 현재안드로이드버전과 API 레벨. 버전 API 레벨장치 % % % % % % % - 3 -

7 . 안드로이드개발환경. Eclipse: Java IDE. AVD(Android Virtual Device, 안드로이드가상기계): 안드로이드 Emulator. DDMS(Dalvik Debug Monitoring Service): 안드로이드를실행하는 Dalvik 가상 기계를모니터하고제어한다. tools/. AAPT(Android Asset Packaging Tool): 배포가능한안드로이드패키지파일(*.apk) 생성한다.. ADB(Android Debug Bridge): 실행중인에뮬레이터에연결할수있다. - 그밖의스마트폰개발환경. Mobile OS 현황 OS 개발업체 개요 개방성 주요단말기 비고 Window Mobile 7 Microsoft PC OS 연동 개방 글로벌제조사 Blackberry RIM RIM 독자 OS 폐쇄 RIM Symbian Nokia 노키아 OS 개방 글로벌제조사 iphone Apple 애플독자 OS 폐쇄 애플 Android Google 오픈소스 개방 글로벌제조사 Bada Samsung 삼성독자 OS 폐쇄 삼성 MeeGo Nokia+Intel Linux 기반오픈소스 개방 - Mobile Platform 현황 OS Window Mobile Blackberry iphone Android 개발언어 Visual Studio Java Objective C Java SDK/DEV Visual Studio BB Web Plugin XCode BB JDE Plugin Android SDK Device 관리 디바이스잠금, 디바이스잠금, 보안관련기능디바이스잠금삭제기능제공삭제관리기능완전하지않음 장점 광범위한개발중앙집중관리시스템보호개방성인프라기업용특화개발자보호개발자선호 단점 감소하는점유율 한국에서인지도낮음 폐쇄성 주요소스노출 - 4 -

8 2 장. 안드로이드개발환경과기본프로그래밍방법 - 개발환경갖추기. Java2 (java.sun.com) 에서 download. jdk 버전 5 이상설치. Eclipse ( download) 에서 download. GALILEO 버전이상설치 (Europa, Ganymede 가능). Android SDK. 에서다운로드. download -> android-sdk_r05-windows.zip, SDK 2.1 new : 22.3MB. 압축을풀고 SDK Setup.exe 를실행하여 Android 를모두받으면: 1.27GB. itory.xml 에서다운로드. ADT(Android Development Tool) Plug-in for Eclipse. menu -> help -> install new software에서설치. Name: Android, Uri: ADT (2010년 3 월). Eclipse Preference setting. Window XP, 고급환경변수에서 Path에 Android SDK tools 디렉토리표시. 참고: Android NDK(Native Development Kit) revision3: C/C++ 코드포팅 - 안드로이드가상기기 (AVD, Android Virtual Device). Android SDK Setup.exe 를실행시켜 AVD 설정및작동. 일반 PC에서핸드폰을실행시키는안드로이드 Emulator - 5 -

9 - 안드로이드응용프로그램프레임워크. android.* com.google.android.maps dalvik.* java.* javax.* junit.* org.apache.http.* org.json org.w3c.dom org.xml.sax org.xmlpull.* - DDMS. DDMS(Dalvik Debug Monitor Service). 안드로이드 AVD 에직접접근하여쓰래드, 메모리등을직접볼수있다. - 안드로이드예제프로그램. API Demo. Bluetooth Chat. Business Card. Contact Manager. Home. Snake. LunarLander. JetBoy. Live Wallpaper. NotePad. Wiktionary 등 - 6 -

10 - 안드로이드디렉토리구조. src: 현재개발한안드로이드소스코드. gen: 안드로이드가자동으로생성한 R.java 소스코드. Android 라이브러리: Android SDK에서제공하는 Java 라이브러리, *.class 파일만있음.. res: 안드로이드가자동으로생성한자원(resource) 폴더. AndroidManifest.xml:. default.properties:. res/drawable: 현재개발한안드로이드응용프로그램에대한모든정보 속성정보 이미지파일. res/anim: 애니메이션 xml 파일. res/layout: XML 파일로서안드로이드화면 layout. res/menu: XML. res/values: 문자열. res/xml: XML 파일 파일로서메뉴정의 - 7 -

11 AndroidManifest.xml - 8 -

12 - 안드로이드자원. R.java: 안드로이드소스코드와 res/ 에있는 XML 파일에의하여생성된자원객체들을 연결시키는 Java 소스코드이며자동으로생성된다. Index를사용하여 XML 파일이 생성한자원객체를표시한다.. public final class R { public static final class attr { public static final class color { public static final int pretytextcolor=0x7f055555; public static final class dimen { public static final int textpointsize=0x7f060000; <-- index. 텍스트문자열, 이미지, 아이콘, 오디오, 동영상등. res 폴더. res/drawable: 이미지파일. res/anim: 애니메이션 xml 파일. res/layout: XML 파일로서안드로이드화면 layout. res/menu: XML. res/values:. res/xml: XML 문자열 파일로서메뉴정의 파일 - 코드에서접근하는방법 R.string.hello : string.xml 자원 xml 파일에서 hello tag의문자열값 String mystring = getresources().getstring(r.string.hello); - Eclipse에서 main.xml, string.xml, 기타 XML 파일을열어서수정하고편집할수있음 - setcontentview(r.layout.main); - 9 -

13 . 책 102page 표 5.1 기본안드로이드자원디렉토리. 책 103page 표 5.2 자원형식과저장위치

14 - 안드로이드응용프로그램골격구조 package com.android.myapplication; import android.app.activity; import android.os.bundle; import android.view.view; public class MyActivity extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Activity protected void onrestoreinstancestate(bundle savedinstancestate) { super.onrestoreinstancestate(savedinstancestate); // savedinstancestate UI public void onrestart( ) { super.onrestart( ); // Activity protected void onstart( ) { super.onstart( ); // Activity. public void onresume( ) { super.onresume( ); // Activity. protected void onsaveinstancestate(bundle savedinstanc estate) { super.onsaveinstancestate(savedinstancestate); // UI savedinstancestate. Activity savedinstancestate Bundle oncreate. public void onpause( ) { super.onpause( ); // Activity. Activity. protected void onstop( ) { super.onstop( ); // Activity. Activity. public void ondestroy( ) { super.ondestroy( ); // Activity

15 - 안드로이드기본프로그래밍방법. 화면구성은 XML 파일로정의 (GUI widget은 Resource XML 로정의). 실제기능은소스코드로프로그램 (GUI 콘트롤은 Android 소스코드에서정의). Android 응용프로그램은세부분으로분리되어구성된다.. Android 소스코드. R,java 파일 (Android build 시스템이자동생성). R.java 파일에는 Resource XML 파일에의하여생성된 GUI 객체에대한 identifier 가저장되어있다.. Resource XML 파일 (Android build 시스템이자동생성). 일반 Java GUI 프로그램에서는 Java 소스코드안에 GUI component 선언과 GUI 콘트롤기능을함께코딩한다.. Android GUI 프로그램에서는 GUI widget 선언과콘트롤기능을분리하여따로코딩한다.. GUI widget 콘트롤기능은 Android Java 프로그램에서코딩한다.. GUI widget 은 XML 파일에정의한다.. 이두부분의연결을 R.java 파일이담당한다.. GUI 콘트롤 Android 프로그램을고치지않고, GUI widget XML 파일만수정하여 다른 GUI 출력을낼수있다.. 혹은 GUI widget XML 파일에내용을추가하여(add, +) 새로운 Android GUI 프로그램을 쉽게개발할수있다. R,java 파일은안드로이드 build 시스템이자동으로수정한다.. 예: Activity 화면출력은 setcontentview(r.layout.main) 한줄이다.. 예 (GUI 에서콘트롤과선언부분분리). 마이크로소프트의 XAML(Extensible Application Markup Language). Adobe의 Flex. Mozilla의 XUL(XML User-interface Language)

16 3 장. 안드로이드응용프로그램개발 - Snake 예제게임프로그램실행 1. 메뉴: File -> New -> Project 선택 2. Android -> Android Project 선택 3. Contents to Create project from existing source 4. Samples 5. Snake 폴더검색 버튼선택 ( 주의: AVD API 버전과 Sample 프로그램 API 버전이동일하여야한다.) 폴더선택 6. Finish 버튼을누른다. - 안드로이드가상장치 (AVD, Android Virtual Device) 생성 1. 안드로이드 SDK에서실행 ( 주의: AVD API 버전과 Sample 프로그램 API 버전이동일하여야한다.) - Snake 실행 1a. Snake 폴더에서마우스오른쪽버튼클릭 -> Run 클릭 ( 주의: AVD 에따라서시간이조금많이걸린다. 인내심을가지고기다려야한다.) (AVD 버전 1.5인경우는대략 30 초정도, 버전 2.1인경우는거의 1 분정도) 1b. 메뉴: Run -> Run Configuration 선택 2b. Android Application 더블클릭 3b. Name 상자에 SnakeRunConfiguration 입력 4b. Run As 아이콘클릭 5b. SnakeRunConfiguration 선택 ( 주의: AVD 에따라서시간이조금많이걸린다. 인내심을가지고기다려야한다.) (AVD 버전 1.5인경우는대략 30 초정도, 버전 2.1인경우는거의 1 분정도)

17 - 안드로이드프로그램개발 1. 메뉴: File -> New -> Project 선택 2. Android -> Android Project 선택 3. Contents create new project in workspace 버튼선택, Use default location 4. Build Target 선택: 선택 생성시킨 AVD 버전과안드로이드프로그램개발 Platform 버전일치. 4. Project name 입력: *** Application name 입력: *** Package name 입력: 예를들어 com.example.android.*** Create Activity 입력: 개발하고자하는안드로이드 Activity 이름 Min SDK Version 설정: 교재에는

18 교재 58page 표 3.1 참조

19 - 생성된폴더구조 AndroidManifest.xml src 폴더: 개발중인안드로이드자바소스코드폴더 gen 폴더: 자동으로생성된폴더로서 R.java 파일이저장 res 폴더: 자원폴더. 참고: 안드로이드에서는소스코드와자원은분리되어따로저장됨. 자원은 xml 파일형태로 저장됨 5. AVD 생성 (AVD 이름은사용자편의대로하면됨.) 6. 개발한안드로이드프로젝트에마우스를위치시킨다. 7. 마우스오른쪽버튼을클릭한다. 8. 메뉴가나오면실행을클릭한다. 9. 기다린다. (30 초~1 분정도) 10. AVD 에안드로이드프로그램이실행된다

20 - 예제프로그램 package com.example.android.now; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import java.util.date; public class Now extends Activity implements View.OnClick Listener { Button btn; /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); btn = new Button(this); btn.setonclicklistener(this); updatetime(); setcontentview(btn); public void onclick(view view) { updatetime(); private void updatetime() { btn.settext(new Date().toString());

21 package com.example.android.now1; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import java.util.date; public class Now1 extends Activity implements View.OnClic klistener { Button btn; /** Called when the activity is first created. */ public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); btn=(button)findviewbyid(r.id.button); btn.setonclicklistener(this); updatetime(); public void onclick(view view) { updatetime(); private void updatetime() { btn.settext(new Date().toString()); <?xml version="1.0" encoding="utf-8"?> <Button xmlns:android = " android:id="@+id/button" android:text="" android:layout_height="wrap_content" />

22 4 장. 기본위젯예제프로그램 - 안드로이드뷰 (view), 위젯 (widget), 레이아웃 (layout). 화면출력클라스: android.view.view, android.view.viewgroup. 안드로이드위젯: android.widget. 안드로이드레이아웃: android.widget.linearlayout - TextView. android.wdiget.textview <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android=" android:id=@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="some sample text here" /> <TextView android:id=@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_text" /> <TextView android:id=@+id/textview03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:lines="2" // 높이는 2줄분량 android:ems="12" // 너비는 12em android:text="@string/autolink_test" />

23 - EditText <?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android=" android:layout_height="wrap_content" android:hint="type here" android:lines="4" /> - Image <?xml version="1.0" encoding="utf-8"?> <ImageView xmlns:android=" /> android:id=@+id/icon" android:layout_height="fill_content" android;adjustviewbounds="true" android:src="drawable/molecule" <-- 현재 drawable 에있는 image 파일설정 - Button <Button android:id=@+id/button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="basic Button" />

24 - FieldDemo( 입력필드 ) package com.android.example.fielddemo; import android.app.activity; import android.os.bundle; import android.widget.edittext; public class FieldDemo extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main) { EditText fld = (EditText)findViewById(R.id.field); fld.settext("licensed under the Apache License, version 2.0" + "You may not use this file " + "except in compliance with the License "); <?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android=" android:id=@+id/field" android:layout_height="fill_parent" android:singlelinet="false" />

25 - CheckBox package com.commonsware.android.basic; import android.app.activity; import android.os.bundle; import android.widget.checkbox; import android.widget.compoundbutton; public class CheckBoxDemo extends Activity implements CompoundButton.OnCheckedChangeListener { CheckBox cb; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); cb=(checkbox)findviewbyid(r.id.check); cb.setoncheckedchangelistener(this); public void oncheckedchanged(compoundbutton buttonview, if (ischecked) { cb.settext( " 체크상태" ); else { boolean ischecked) { cb.settext( " 체크되지않은상태" ); <?xml version="1.0" encoding="utf-8"?> <CheckBox xmlns:android=" /> android:id="@+id/check" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 체크되지않은상태"

26 - RadioButton package com.commonsware.android.basic; import android.app.activity; import android.os.bundle; public class RadioButtonDemo extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); <?xml version="1.0" encoding="utf-8"?> <RadioGroup xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 가위" /> <RadioButton android:id="@+id/radio2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 바위" /> <RadioButton android:id="@+id/radio3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 보" /> </RadioGroup>

27 5 장. 레이아웃을이용한사용자인터페이스설계 - 코드에서레이아웃만들기 (LinearLayout) import android.app.activity; import android.os.bundle; public class LinearLayout extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); TextView text1 = new TextView(this); text1.settext(" 안녕! ); TextView text2 = new TextView(this); text2.settext(" 나는둘째. 줄바꿈이필요함. ); text2.settextsize((float) 60); LinearLayout ll = new LinearLayout(this); ll.setorientation(linearlayout.vertical); ll.addview(text1); ll.addview(text2); setcontentview(ll);

28 - XML 로레이아웃만들기 (LinearLayout) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" android:text=" 안녕! /> <TextView android:layout_height="wrap_content" android:textsize="60px" android:text=" 나는둘째, 줄바꿈이필요함. /> </LinearLayout>

29 - LinearLayout 예제 package com.commonsware.android.containers; import android.app.activity; import android.os.bundle; import android.view.gravity; import android.text.textwatcher; import android.widget.linearlayout; import android.widget.radiogroup; import android.widget.edittext; public class LinearLayoutDemo extends Activity implements RadioGroup.OnCheckedChangeListener { RadioGroup orientation; RadioGroup gravity; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); orientation=(radiogroup)findviewbyid(r.id.orientation); orientation.setoncheckedchangelistener(this); gravity=(radiogroup)findviewbyid(r.id.gravity); gravity.setoncheckedchangelistener(this); public void oncheckedchanged(radiogroup group, int checkedid) { if (group==orientation) { if (checkedid==r.id.horizontal) { orientation.setorientation(linearlayout.horizontal); else { orientation.setorientation(linearlayout.vertical); else if (group==gravity) { if (checkedid==r.id.left) { gravity.setgravity(gravity.left);

30 else if (checkedid==r.id.center) { gravity.setgravity(gravity.center_horizontal); else if (checkedid==r.id.right) { gravity.setgravity(gravity.right); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <RadioGroup android:id="@+id/orientation" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5px"> <RadioButton android:id="@+id/horizontal" android:text=" 가로" /> <RadioButton android:id="@+id/vertical" android:text=" 세로" /> </RadioGroup> <RadioGroup android:id="@+id/gravity" android:orientation="vertical" android:layout_height="wrap_content" android:padding="5px"> <RadioButton android:id="@+id/left" android:text=" 왼쪽" /> <RadioButton android:id="@+id/center" android:text=" 가운데" /> <RadioButton android:id="@+id/right" android:text=" 오른쪽" /> </RadioGroup> </LinearLayout>

31 - RelativeLayout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=" android:layout_height="wrap_content" android:padding="5px"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="url:" android:paddingtop="15px" /> <EditText <Button android:layout_height="wrap_content" /> android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 확인" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 취소" /> </RelativeLayout>

32 - TableLayout package com.commonsware.android.containers; import android.app.activity; import android.os.bundle; public class TableLayoutDemo extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android=" android:layout_height="fill_parent" android:stretchcolumns="1"> <TableRow> <TextView android:text="url:" /> <EditText android:id="@+id/entry" android:layout_span="3" /> </TableRow> <View android:layout_height="2px" android:background="#0000ff" /> <TableRow> <Button android:id="@+id/cancel" android:layout_column="2" android:text=" 취소" /> <Button </TableRow> </TableLayout> android:id="@+id/ok" android:text=" 확인" />

33 - Scroll <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=" android:layout_height="wrap_content"> <TableLayout android:layout_height="fill_parent" android:stretchcolumns="0"> <TableRow> <View android:layout_height="80px" android:background="#000000" /> <TextView android:text="#000000" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#440000" /> <TextView android:text="#440000" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#884400" /> <TextView android:text="#884400" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#aa8844" /> <TextView android:text="#aa8844" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#ffaa88" /> <TextView android:text="#ffaa88" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#ffffaa" /> <TextView android:text="#ffffaa" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> <TableRow> <View android:layout_height="80px" android:background="#ffffff" /> <TextView android:text="#ffffff" android:paddingleft="4px" android:layout_gravity="center_vertical" /> </TableRow> </TableLayout> </ScrollView>

34 package com.commonsware.android.containers; import android.app.activity; import android.os.bundle; public class ScrollViewDemo extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main);

35 6 장. 선택기능위젯 - ArrayAdapter 사용하기 String[] items={"this", "is", "a", "really", "silly", "list"; ArrayAdapter<String> (this, android.r.layout.simple_list_item_1, items); - 기능: 문자열을안드로이드위젯에매핑시키는기능 - ListView 예제 package com.commonsware.android.selection; import android.app.activity; import android.os.bundle; import android.app.listactivity; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.textview; public class ListViewDemo extends ListActivity { TextView selection; String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); setlistadapter(new ArrayAdapter<String>(this, android.r.layout.simple_list_item_1, items)); selection=(textview)findviewbyid(r.id.selection);

36 public void onlistitemclick(listview parent, View v, int p osition, long id) { selection.settext(items[position]); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:id="@+id/selection" android:layout_height="wrap_content" /> <ListView android:id="@android:id/list" android:layout_height="fill_parent" android:drawselectorontop="false" /> </LinearLayout>

37 - Spin Control public class SpinnerDemo extends Activity implements AdpaterView.OnItemSelectedListener { TextView selection; String[ ] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); selection=(textview)findviewbyid(r.id.selection); Spinner spin=(spinner)findviewbyid(r.id.spinner); spin.setonitemselectedlistener(this); ArrayAdapter<String> aa=new ArrayAdapter<String> (this, android.r.layout.simple_spinner_item, items); aa.setdropdownviewresource (android.r.layout.simple_spinner_dropdown, items); spin.setadapter(aa); public void onitemselected(adapterview<?> parent, View v, int position, long id) { selection.settext(item[position]); public void onnothingselected(adapterview<?> parent) { selection.settext(" ");

38 <?xml version="1.0" encoding="utf-8"> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" /> <Spinner android:layout_height="wrap_content" android:drawselectorontop="true' /> </LinearLayout>

39 -Grid package com.commonsware.android.selection; import android.app.activity; import android.content.context; import android.os.bundle; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.button; import android.widget.gridview; import android.widget.textview; public class GridDemo extends Activity implements AdapterView.OnItemSelectedListener { TextView selection; String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); selection=(textview)findviewbyid(r.id.selection); GridView g=(gridview) findviewbyid(r.id.grid); g.setadapter(new FunnyLookingAdapter(this, android.r.layout.simple_list_item_1, items)); g.setonitemselectedlistener(this); public void onitemselected( AdapterView<?> parent, View v, int position, long id) { selection.settext(items[position]);

40 public void onnothingselected(adapterview<?> parent) { selection.settext(""); private class FunnyLookingAdapter extends ArrayAdapter { Context ctxt; FunnyLookingAdapter(Context ctxt, int resource, String[] items) { super(ctxt, resource, items); this.ctxt=ctxt; public View getview(int position, View convertview, ViewGroup parent) { TextView label=(textview)convertview; if (convertview==null) { convertview=new TextView(ctxt); label=(textview)convertview; label.settext(items[position]); return(convertview);

41 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" /> <GridView android:layout_height="fill_parent" android:verticalspacing="35px" android:horizontalspacing="5px" android:numcolumns="auto_fit" android:columnwidth="100px" android:stretchmode="columnwidth" android:gravity="center" /> </LinearLayout>

42 - 자동입력 ( 타이핑줄이기 ) public class AutoCompleteDemo extends Activity implement s TextWatcher { TextView selection; AutoCompleteTextView edit; String[ ] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); selection=(textview)findviewbyid(r.id.selection); edit=(autocompletetextview)findviewbyid(r.id.edit); edit.addtextchangedlistener(this); edit.setadapter(new ArrayAdapter<String> (this, android.r.layout.simple_dropdown_item_line, items)); public void ontextchanged(charsequence s, int start, int before, int count) { selection.settext(edit.gettext()); public void beforetextchanged(charsequence s, int start, int count, int after) { public void aftertextchanged(editable s) {

43 <?xml version="1.0" encoding="utf-8"> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" /> <AutoCompleteTextView android:layout_height="wrap_content" android:completionthreshold="3" /> </LinearLayout>

44 7 장. 리스트고급활용 - Static List package com.commonsware.android.fancylists.two; import android.app.activity; import android.os.bundle; import android.app.listactivity; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.textview; public class StaticDemo extends ListActivity { TextView selection; String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); setlistadapter(new ArrayAdapter<String>(this, R.layout.row, R.id.label, items)); selection=(textview)findviewbyid(r.id.selection); public void onlistitemclick(listview parent, View v, int p osition, long id) { selection.settext(items[position]);

45 - main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" /> <ListView android:layout_height="fill_parent" android:drawselectorontop="false" /> </LinearLayout> - row.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/icon" android:layout_width="22px" android:paddingleft="2px" android:paddingright="2px" android:paddingtop="2px" android:layout_height="wrap_content" android:src="@drawable/ok" /> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="44sp" /> </LinearLayout>

46 - Dynamic List package com.commonsware.android.fancylists.three; import android.app.activity; import android.os.bundle; import android.app.listactivity; import android.view.view; import android.view.viewgroup; import android.view.layoutinflater; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.listview; import android.widget.textview; public class DynamicDemo extends ListActivity { TextView selection; String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); setlistadapter(new IconicAdapter(this)); selection=(textview)findviewbyid(r.id.selection); public void onlistitemclick(listview parent, View v, int p osition, long id) { selection.settext(items[position]); class IconicAdapter extends ArrayAdapter { Activity context; IconicAdapter(Activity context) { super(context, R.layout.row, items); this.context=context;

47 public View getview(int position, View convertview, ViewGroup parent) { LayoutInflater inflater=context.getlayoutinflater(); View row=inflater.inflate(r.layout.row, null); TextView label=(textview)row.findviewbyid(r.id.label); label.settext(items[position]); if (items[position].length()>4) { ImageView icon=(imageview)row.findviewbyid(r.id.icon); icon.setimageresource(r.drawable.delete); return(row);

48 - main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" /> <ListView android:layout_height="fill_parent" android:drawselectorontop="false" /> </LinearLayout> - row.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/icon" android:layout_width="22px" android:paddingleft="2px" android:paddingright="2px" android:paddingtop="2px" android:layout_height="wrap_content" android:src="@drawable/ok" /> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="40sp" /> </LinearLayout>

49 8 장. 고급위젯과컨테이너 - Chrono package com.commonsware.android.fancy; import android.app.activity; import android.os.bundle; import android.app.datepickerdialog; import android.app.timepickerdialog; import android.view.view; import android.widget.button; import android.widget.datepicker; import android.widget.timepicker; import android.widget.textview; import java.text.dateformat; import java.util.calendar; public class ChronoDemo extends Activity { DateFormat fmtdateandtime=dateformat.getdatetimeinstance(); TextView dateandtimelabel; Calendar dateandtime=calendar.getinstance(); DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() { public void ondateset(datepicker view, int year, int month OfYear, int dayofmonth) { dateandtime.set(calendar.year, year); dateandtime.set(calendar.month, monthofyear); dateandtime.set(calendar.day_of_month, dayofmonth); updatelabel(); ; TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() { public void ontimeset(timepicker view, int hourofday, int minute) { dateandtime.set(calendar.hour_of_day, hourofday); dateandtime.set(calendar.minute, minute); updatelabel(); ;

50 public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); Button btn=(button)findviewbyid(r.id.datebtn); btn.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { new DatePickerDialog(ChronoDemo.this, d, dateandtime.get(calendar.year), dateandtime.get(calendar.month), dateandtime.get(calendar.day_of_month)).show(); ); btn=(button)findviewbyid(r.id.timebtn); btn.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { new TimePickerDialog(ChronoDemo.this, t, dateandtime.get(calendar.hour_of_day), dateandtime.get(calendar.minute), true).show(); ); dateandtimelabel=(textview)findviewbyid(r.id.dateandtime); updatelabel(); private void updatelabel() { dateandtimelabel.settext(fmtdateandtime.format(dateandtime.gettime()));

51 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" <TextView <Button <Button android:orientation="vertical" android:layout_height="fill_parent"> android:layout_height="wrap_content" /> android:layout_height="wrap_content" android:text=" 날짜선택" /> android:layout_height="wrap_content" android:text=" 시간선택" /> </LinearLayout>

52 - 시계 package com.commonsware.android.fancy; import android.app.activity; import android.os.bundle; public class ClocksDemo extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <AnalogClock android:id="@+id/analog" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_alignparenttop="true" /> <DigitalClock android:id="@+id/digital" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_below="@id/analog" /> </RelativeLayout>

53 - DatePicker public class HelloDatePicker extends Activity { private TextView mdatedisplay; private int myear; private int mmonth; private int mday; static final int DATE_DIALOG_ID=0; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mdatedisplay = (TextView) findviewbyid(r.id.datedisplay); mpickdate = (Button) findviewbyid(r.id.pickdate); mpickdate.setonclicklistener(new View.OnClickListene r() { public void onclick(view v) { showdialog(date_dialog_id); ); final Calendar c = Calender.getInstance(); myear = c.get(calender.year); mmonth = c.get(calender.month); mday = c.get(calender.day_of_month); updatedisplay(); private void updatedisplay() { mdatedisplay.settext ( new StringBuilder().append(mMonth+1).append("-").append(mDay).append("-").append(mYear).append("-"));

54 protected Dialog oncreatedialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, mdatesetlistener, m Year, mmonth, mday); return null; private DatePickerDialog.OnDateSetListener mdatesetli stener mdatesetlistener= new DatePickerDialog.OnDateSetListener() { public void ondateset(datepicker view, int year, int month OfYear, int dayofmonth) { myear = year; mmonth = monthofyear; mday = dayofmonth; updatediaplay(); ;

55 - Flipper package com.commonsware.android.flipper1; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.viewflipper; public class FlipperDemo extends Activity { ViewFlipper flipper; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); flipper=(viewflipper)findviewbyid(r.id.details); Button btn=(button)findviewbyid(r.id.flip_me); btn.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { flipper.shownext(); );

56 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <Button android:layout_height="wrap_content" android:text=" 페이지넘김" /> <ViewFlipper android:layout_height="fill_parent"> <TextView <TextView <TextView </ViewFlipper> </LinearLayout> android:layout_height="wrap_content" android:textstyle="bold" android:textcolor="#ff00ff00" android:text=" 첫번째페이지" /> android:layout_height="wrap_content" android:textstyle="bold" android:textcolor="#ffff0000" android:text=" 두번째페이지" /> android:layout_height="wrap_content" android:textstyle="bold" android:textcolor="#ffffff00" android:text=" 세번째페이지" />

57 9 장. 메뉴 - OptionMenu, ContextMenu - MenuDemo package com.commonsware.android.menus; import android.app.activity; import android.os.bundle; import android.app.listactivity; import android.view.contextmenu; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.textview; public class MenuDemo extends ListActivity { TextView selection; String[] items={"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "aliquet", "mollis", "etiam", "vel", "erat", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"; public static final int EIGHT_ID = Menu.FIRST+1; public static final int SIXTEEN_ID = Menu.FIRST+2; public static final int TWENTY_FOUR_ID = Menu.FIRST+3; public static final int TWO_ID = Menu.FIRST+4; public static final int THIRTY_TWO_ID = Menu.FIRST+5; public static final int FORTY_ID = Menu.FIRST+6; public static final int ONE_ID = Menu.FIRST+7; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); setlistadapter(new ArrayAdapter<String>(this, android.r.layout.simple_list_item_1, items)); selection=(textview)findviewbyid(r.id.selection); registerforcontextmenu(getlistview()); public void onlistitemclick(listview parent, View v, int p osition, long id) { selection.settext(items[position]); public void oncreatecontextmenu(contextmenu menu, View v, ContextMenu.ContextMenuInfo menuinfo) { populatemenu(menu);

58 public boolean oncreateoptionsmenu(menu menu) { populatemenu(menu); return(super.oncreateoptionsmenu(menu)); public boolean onoptionsitemselected(menuitem item) { return(applymenuchoice(item) super.onoptionsitemselected(item)); public boolean oncontextitemselected(menuitem item) { return(applymenuchoice(item) super.oncontextitemselected(item)); private void populatemenu(menu menu) { menu.add(menu.none, ONE_ID, Menu.NONE, "1 픽셀"); menu.add(menu.none, TWO_ID, Menu.NONE, "2 픽셀"); menu.add(menu.none, EIGHT_ID, Menu.NONE, "8 픽셀"); menu.add(menu.none, SIXTEEN_ID, Menu.NONE, "16 픽셀"); menu.add(menu.none, TWENTY_FOUR_ID, Menu.NONE, "24 픽셀"); menu.add(menu.none, THIRTY_TWO_ID, Menu.NONE, "32 픽셀"); menu.add(menu.none, FORTY_ID, Menu.NONE, "40 픽셀"); private boolean applymenuchoice(menuitem item) { switch (item.getitemid()) { case ONE_ID: getlistview().setdividerheight(1); return(true); case EIGHT_ID: getlistview().setdividerheight(8); return(true); case SIXTEEN_ID: getlistview().setdividerheight(16); return(true); case TWENTY_FOUR_ID: getlistview().setdividerheight(24); return(true); case TWO_ID: getlistview().setdividerheight(2); return(true); case THIRTY_TWO_ID: getlistview().setdividerheight(32); return(true); case FORTY_ID: getlistview().setdividerheight(40); return(true); return(false);

59 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" android:background="#eeeeee" /> <ListView android:layout_height="fill_parent" android:drawselectorontop="false" /> </LinearLayout

60 10 장. Webkit - Browser1 package com.commonsware.android.webkit; import android.app.activity; import android.os.bundle; import android.webkit.webview; public class BrowserDemo1 extends Activity { WebView browser; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); browser=(webview)findviewbyid(r.id.webkit); browser.loadurl(" <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <WebView android:id="@+id/webkit" android:layout_height="fill_parent" /> </LinearLayout>

61 - Browser2 package com.commonsware.android.webkit; import android.app.activity; import android.os.bundle; import android.webkit.webview; public class BrowserDemo2 extends Activity { WebView browser; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); browser=(webview)findviewbyid(r.id.webkit); browser.loaddata ("<html><body>hello, world! 안녕하세요!</body></html>", "text/html", "UTF-8"); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <WebView android:id="@+id/webkit" android:layout_height="fill_parent" /> </LinearLayout>

62 - Browser3 package com.commonsware.android.webkit; import android.app.activity; import android.os.bundle; import android.webkit.webview; import android.webkit.webviewclient; import java.util.date; public class BrowserDemo3 extends Activity { WebView browser; public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); browser=(webview)findviewbyid(r.id.webkit); browser.setwebviewclient(new Callback()); loadtime(); void loadtime() { String page="<html><body><a href=\"clock\">" +new Date().toString() +"</a></body></html>"; browser.loaddatawithbaseurl("x-data://base", page, "text/html", "UTF-8", null); private class Callback extends WebViewClient { public boolean shouldoverrideurlloading(webview view, String url) { loadtime(); return(true); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <WebView android:id="@+id/webkit" android:layout_height="fill_parent" /> </LinearLayout>

63 11 장. 화면회전 * - RotationThree package com.commonsware.android.rotation.three; import android.app.activity; import android.content.intent; import android.content.res.configuration; import android.net.uri; import android.os.bundle; import android.view.view; import android.widget.button; import android.util.log; public class RotationThreeDemo extends Activity { static final int PICK_REQUEST=1337; Button viewbutton=null; Uri contact=null; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setupviews(); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode==pick_request) { if (resultcode==result_ok) { contact=data.getdata(); viewbutton.setenabled(true); public void onconfigurationchanged(configuration newco nfig) { super.onconfigurationchanged(newconfig); setupviews(); private void setupviews() { setcontentview(r.layout.main); Button btn=(button)findviewbyid(r.id.pick); btn.setonclicklistener(new View.OnClickListener() { public void onclick(view view) { Intent i=new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts/people")); startactivityforresult(i, PICK_REQUEST); );

64 viewbutton=(button)findviewbyid(r.id.view); viewbutton.setonclicklistener(new View.OnClickListen er() { public void onclick(view view) { startactivity(new Intent(Intent.ACTION_VIEW, contact)); ); viewbutton.setenabled(contact!=null); main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <Button android:id="@+id/pick" android:layout_height="fill_parent" android:layout_weight="1" android:text=" 선택" android:enabled="true" /> <Button android:id="@+id/view" android:layout_height="fill_parent" android:layout_weight="1" android:text=" 보기" android:enabled="false" /> </LinearLayout>

65 12 장. 그래픽스와애니메이션 12.0 소개. View class, Canvas class, Paint class - 화면에원가를그리려면. Canvas: 화폭. Paint: 물감( 색상, 안티엘리어싱, 스타일, 그래디언트) import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; private static class ViewWithRedDot extends View { public ViewWithRedDot(Context context) { super(context): protected void ondraw(canvas canvas) { canvas.drawcolor(color.black); Paint circlepaint = new Paint( ); circlepaint.setcolor(color.red); canvas.drawcircle( canvas.getwidth()/2, canvas.getheight()/2, canvas.getwidth()/3, circlepaint); public class WithRedDot extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new ViewWithRedDot(this));

66 차원그래픽스 (developer.android.com) 안드로이드는커스텀(custom) 안드로이드라이브러리를통한 2차원그래픽스와 OpenGL ES v1.0을통한 3 차원그래픽스를제공한다. 2차원그래픽스 API(Application Programming Interface) 는드로어블(Drawable) 패키지에서제공되고, OpenGL API는 OpenGL ES 패키지와 OpenGL 유틸리티에서제공된다. OpenGL ES는여기서논의하지않 는다. OpenGL ES 전문서적을참고하기바란다. 2차원그래픽스와 3 차원그래픽스는다른부분이많기때문에, 그래픽스응용을개발할 때는응용의요구사항이무엇인지를분명히파악하는것이중요하다. 왜냐하면간단하고고 정적인그래픽스응용은 안드로이드에서 2 차원그래픽스를사용하여충분히구현할수있기때문이다. 2 차원그래픽스를구현하는방법에는다음두가지방법이있다. 그래픽스를구현하는두가지방법 (1) Layout 위에 View 객체를사용하여그래픽스와애니메이션을구현하는방법이있다. 이방법에서는그림과애니메이션은안드로이드시스템 View 계층의드로잉(drawing) 과정 을통하여이루어진다. 개발자는단순히 View 를상속받아개발을수행하면된다. 이방법은 변화가많지않은간단한그래픽스혹은높은성능이필요하지않는간단한게임의경우에 적합하다. 즉, 예를들어, 이미지, 도형, 칼라, 혹은간단한애니메이션을하는경우에는, Layout을사용하여 View에그림을그리거나혹은 ImageView 에그림을그린다. (2) Canvas 객체위에직접그래픽스를그리는방법이있다. 이방법을사용하면적절한 클래스의 draw() 메소드를호출하여그림을그린다. 예를들어, Canvas의 drawpicture() 메소드를호출하여그림을그릴수있다. 이방법은비디오게임과같이 Canvas 위에규칙 적으로그림을다시그려야하는경우에적합하다. 이방법의구현에는두가지방법이있 다. Canvas에대해서는 절에서좀더자세히다룬다. (2.1) 사용자인터페이스(UI) 와동일한쓰래드에서, Layout 위에커스텀 View 컴포넌트를 생성하고, invalidate() 를호출하고 ondraw() 콜백(callback) 함수를사용하여처리 하는방법이있다. (2.2) 사용자인터페이스와다른쓰래드에서, SurfaceView를사용하여쓰래드가허용하는 가장빠른속도로 Canvas 에그림을그리는방법이있다. SurfaceView에대해서는 절에서좀더자세히설명한다. 지금부터는그래픽스와관련된안드로이드클래스들을하나씩설명한다. 들은 developer.android.com 에서찾을수있다. 좀더상세한자료

67 Drawable 2차원그래픽스라이브러리는 android.graphics.drawable 과 android.view.animation 패 키지에서찾을수있다. 이절에서는 Drawable 객체를사용한간단한그래픽스, Drawable 객체의서브클래스, 그리고프레임애니메이션과트윈애니메이션( 이동, 확장, 회전) 을소개 한다. Drawable 은안드로이드에서제공하는그림그리기에대한최상위객체이다. Drawable 클래스는 AnimationDrawable, BitmapDrawable, ClipDrawable, Color Drawable, ShapeDrawable, PictureDrawable, LayerDrawable 등등의서브클래스를제공한다. 개발 자는자신이개발하고자하는응용을위하여이클래스들을다시확장하여사용할수있다. Drawable을정의하고활용하는데에는 3 가지방법이있다. 즉, 개발자는개발하고자하는 프로젝트자원에저장된이미지, Drawable의속성을규정한 XML 파일, 혹은클래스의생 성자를이용하여 Drawable 을정의하여활용할수있다. 생성자를이용한방법은이미알고 있는방법이기때문에앞의두가지경우만을설명한다 이미지로부터생성 개발하는응용에그래픽스이미지를더하는간단한방법은프로젝트의자원폴더인 res/drawable/ 에이미지를저장하는것이다. 저장가능한이미지파일형태는 *.PNG( 가장 적합), *.JPG( 사용가능), *.BMP( 사용가능), *.GIF( 사용가능, 비적합) 등이다. 이기법은아 이콘, 로고, 혹은게임에서사용하는간단한그래픽이미지에적합하다. 폴더에저장된이미 지는안드로이드소스코드나 XML 파일에서참조할수있다. 참조할때는확장자 PNG, JPG, BMP, GIF 를제외하고파일이름을직접사용하면된다. 예제소스코드 다. 다음은폴더에저장된영상을사용하여 ImageView를생성하고 Layout에더하는코드이 LinearLayout mlinearlayout; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mlinearlayout = new LinearLayout(this); ImageView im = new ImageView(this); im.setimageresource(r.drawable.my_image); im.setadjustviewbounds(true); im.setlayoutparams(new Gallery.LayoutParams.WRAP_CONTENT); mlinearlayout.addview(im); setcontentview(mlinearlayout);

68 그밖의경우에서는, 이미지자원을 Drawable 객체로사용할수있다. 다음은코드이다. Resources res = mcontext.getresource(); Drawable myimage = res.getdrawble(r.drawable.my_image); XML 파일로부터생성 Drawable 객체를 XML 파일에정의할수있다. 비록 Drawable 객체의속성이프로그램 수행중에변경되더라도 Drawable 객체를 XML 파일에정의할수있다. Drawable 객체를 정의한 XML 파일은 res/drawable/ 폴더에저장한다. 다음은간단히 Drawable 자원을 XML 파일의 ImageView 에저장하는방법이다. 예제 XML 소스코드 <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#55ff0000" android:src="@drawable/my_image"/> 안드로이드소스코드에서는 Resources.getDrawable() 메소드를호출하여객체를출력한 다. Inflate() 메소드를지원하는 Drawable 서브클래스는 XML도정의될수있으며프로그 램에서사용될수있다. 다음은 TansitionDrawable 객체를사용한간단한예이다. TransitionDrawable은 LayerDrawable 을확장한것으로서첫번째와두번째층사이에서이미지가서서히사라 지는현상을구현할때사용한다. 예제소스코드 <transition xmlns:android=" <item android:drawable="drawable/expand_collapse"> </transition> 폴더 res/drawable/expand_collapse.xml 에저장된이 XML 파일을사용하여, 다음안드 로이드코드는 TransitionDrawable 을 ImageView 에나타낸다. Resources res = mcontext.getresources(); TransitionDrawable transition = (TransitionDrawable) res.getdrawable(r.drawable.expand_collapse); ImageView image = (ImageView) findviewbyid(r,id.toggle_image); image.setimagedrawable(transition); 다음코드를수행하면이 transition이 1 초동안수행된다

69 transition.starttransition(1000); 다음은 Drawable 클래스의내용이다. - 인터페이스 Animatable Drawable Callback 애니메이션을위하여필요한인터페이스애니메이션을위한 Drawable - 클래스 AnimationDrawable Frame 애니메이션을위한객체 BitmapDrawable Bitmap 을객체화하여기울기, 확장, 배치 ClipDrawable Drawable 을클립하는객체 ColorDrawable 지정된색깔로 Canvas를채우는 Drawable Drawable 그림을그리는대표적인객체 Drawable.ConstantState DrawableContainer DrawableContanier.DrawableContainerState GradientDrawable Color gradient drawable 객체 InsetDrawable 다른 Drawable을삽입하는객체 LayerDrawable 다른 Drawable 배열을관리하는 Drawable LevelListDrawable 다른 Drawable을관리하는자원 NinePatchDrawable 확장가능한 Bitmap PaintDrawable Paint로그림을그리는 Drawable PictureDrawable Picture를객체로만드는 Drawable RotateDrawable 다른 Drawable을회전시키는 Drawable ScaleDrawable 다른 Drawable을확장시키는 Drawable ShapeDrawable 기본 Shape를그리는 Drawable 객체 ShapeDrawable.ShaderFactory Factory 객체를정의하는기본클래스 StateListDrawable 여러개의이미지를 Drawable에부여 TransitionDrawable LayerDrawable의확장 - Enums GradientDrawable.Orientation Gradient의방향을조정 Canvas 그림을그리거나애니메이션을하고자할때, Canvas 객체를사용하는방법도있다. Canvas 는그림이그려지는실제표면처럼작동하여그림을그린다. Canvas 객체는개발자 의모든 draw" 명령을수행한다. Canvas에그림을그릴때에는 4 가지요소가필요하다. 하나는그림의픽셀을저장할 Bitmap 이고, 두번째는 draw 호출을실행할 Canvas 자체이 고, 세번째는 Rect, Path, Text, Bitmap 등의기본그림요소(drawing primitive) 이고, 마 지막으로는색과스타일을지정하는 Paint 객체이다. 즉, Canvas를통하여그리는그림은

70 실제로는하위 Bitmap 객체위에서실행되며 Bitmap 은윈도우위에구성된다. ondraw() 콜백메소드를이용하여그림을그릴때에, 개발자는단지 Canvas에자신의 그림을그리는코드를위치시키면된다. 다음은간단한예제코드이다. 이코드는 Bitmap 객체 b를선언하고이객체를 Canvas c 에설정하는방법을제시한다. Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); Canvas는정의된 Bitmap 에그림을그린다. 그림을 Canvas에그린후에는 Bitmap을다른 Canvas로 Canvas.drawBitmap(Bitmap,...) 방식을사용하여옮길수도있다. 그림을그릴 때에는 View.onDraw() 혹은 SurfaceHolder.lockCanvas() 방식을사용하는것이좋다. Canvas 클래스는 drawbitmap(...), drawrect(...), drawtext(...) 도가지고있다. 다음은 Canvas 클래스의메소드들이다. 등의자체드로잉메소드 - 내포클래스 enum enum Canvas.EdgeType Canvas.VertexMode - 상수 int ALL_SAVE_FLAG 모든파일저장 int CLIP_SAVE_FLAG 현재클립저장 int CLIP_TO_LAYER_SAVE_FLAG 레이어바운드클립 int FULL_COLOR_LAYER_SAVE_FLAG int HAS_ALPHA_LAYER_SAVE_FLAG int MATRIX_SAVE_FLAG 현재매트릭스저장 - Public constructor Canvas() 빈래스터 canvas를생성 Canvas(Bitmap bitmap) 지정된 bitmap을사용하여 canvas 생성 Canvas(GL gl) 지정된 gl context를사용하여 canvas 생성 - Public Method 다음은 Canvas 의클래스의메소드들이다. Canvas 클래스가가지고있는메소드는매우 많으며그중에서일부만제시한다. void void drawbitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasalpha, Paint paint) drawbitmap(bitmap bitmap, Rect src, Rect dst, Paint paint)

71 void void void void void void void void void void void void void void void void void void void void 등등 drawbitmap(bitmap bitmap, float left, float top, Pain t paint) drawbitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasalpha, Paint paint) drawbitmap(bitmap bitmap, Rect src, RectF dst, Paint paint) drawbitmapmesh(bitmap bitmap, int meshwidth, int mes hheight, float[] verts, int vertoffset, int[] colors, int coloroffset, Paint paint) drawcircle(float cx, float cy, float radius, Paint paint) drawcolor(int color) drawcolor(int color, PorterDuff.Mode mode) drawline(float startx, float starty, float stopx, float stopy, Paint paint) drawlines(float[] pts, Paint paint) drawlines(float[] pts, int offset, int count, Paint paint) drawoval(rectf oval, Paint paint) drawpaint(paint paint) drawpath(path path, Paint paint) drawpicture(picture picture, RectF dst) drawpicture(picture picture, Rect dst) drawpicture(picture picture) drawpoint(float x, float y, Paint paint) drawpoints(float[] pts, int offset, int count, Paint paint) drawpoints(float[] pts, Paint paint) drawpostext(char[] text, int index, int count, float[] pos, Paint paint) View View 클래스는사용자인터페이스를위한기본객체이다. android.view.view 에존재한 다. View는스크린의사각형영역으로서드로잉과이벤트- 핸들링을처리한다. View는위 젯(widget) 의기본클래스이다. ViewGroup 클래스는 View 클래스의서브클래스로서 Layout 을담당한다. 윈도우의 View 는트리구조로구성된다. 안드로이드 Java 코드에서 View를선언할수도있고 XML 파일에서 View 를선언할수도있다. View를구성한다음 에는다음을수행하여야한다.. TextView의 text 결정. View 초점결정: requestfocus() 메소드에의한초점결정. 이벤트-핸들링을위한 Listener 구성. Visibility 결정: View 의가시성결정(setVisibility(int)) 커스텀 View를구현하기위해서는다음의메소드를 override 하여야한다. 그러나일반적 으로는 ondraw() 만 override 하여도그림을그리는것은가능하다

72 분류 메소드 설명 생성자 View 생성자 Creation View와하위객체들이모두 onfinishinflate() 전개되면호출된다. onmeasure(int, int) View와하위객체들의크기를결정하기위하여호출 Layout onlayout(boolean, int, int, int, int) View가하위자식들에게크기와위치와부여할때 onsizechanged(int, int, int, int) View의크기가변경되었을때 Drawing ondraw 그림을그려야할때 onkeydown Key down 이벤트 Event processing onkeyup Key up 이벤트 ontrackballevent Trackball motion 이벤트 ontouchevent Touch screen motion 이벤트 Focus onfocuschangedevent() View focus 조정 onwindowfocuschanged() View window focus 변화 onattachedtowindow() View window에연결 Attaching ondetachedfromwindow() View window로부터분리 onwindowvisibilitychanged() Window visibility 변화 만약안드로이드응용이많은양의그래픽을실행하지않거나혹은낮은프레임처리율 에서실행된다면, 일반적으로커스텀 View 컴포넌트를생성하여 View.onDraw() 에서그림 을그리는것이대부분이다. 시작하는방법은, 우선 View 클래스를확장하고 ondraw() 콜백메소드를정의한다. 이 메소드는안드로이드시스템에의하여호출되어 View 에그림을그리도록한다. 호출이전 에 View 객체는 invalidate() 호출에의하여 invalidate() 된다 ViewGroup ViewGroup은다른 View를포함할수있는특별한 View이며 Layout과 View 컨테이너 를포함한다. 또한 ViewGroup은 Layout 파라메타를정의한 ViewGroup.LayoutParams 클 래스를포함하고있다. ViewGroup에서 Activity Layout 을정의한다. ViewGroup의직접 서브클래스는 Layout을정의하는 AbsoluteLayout, FrameLayout, LinearLayout, RelativeLayout, SlidingDrawer, AdapterView<T extends Adapter> 이다 SurfaceView SurfaceView는 View 클래스의특별한하위클래스이다. 이객체의목적은멀티쓰래딩 환경에서두번째쓰래드를생성하여그림을그릴수있도록하는것이다. 즉, 첫번째쓰 래드에서 View 객체가그림을그리는것을완료할때까지기다리지않고, 응용의 SurfaceView 객체가두번째쓰래드를이용하여바로자신의 Canvas에그림을그리도록 하는것이다. 응용을개발하기위해서는 SurfaceView 클래스를확장하고인터페이스 SurfaceHolder.Callback 을구현하여야한다. 이인터페이스는사용할 Surface 의생성, 변

73 화, 그리고소멸에대하여알려준다. 이중에서 Surface 생성이벤트가가장중요하다. 이 이벤트가있어야언제 SurfaceView 가생성되어그림을그릴수있는지알수있다 Shape Shape 클래스는 java.lang.object 를상속한다. 직접하위클래스는 PathShape, RectShape 이다. 간접하위클래스는 ArcShape, OvalShape, RoundRectShape 이다. Shape 클래스는그래픽도형을 Canvas 위에 draw() 메소드를사용하여그린다. ShapeDrawable() 을사용하면더욱정교한그래픽조정을할수있다. - Public constructor Shape() - Public Method Shape() clone() this 객체를생성하여반환 abstract void draw(canvas canvas, Paint paint) 현재도형 Canvas에 Paint로그림 final float getheight() 도형높이반환 final float getwidth() 도형넓이반환 boolean hasalpha() 도형불투명성검사 final void resize(float width, float height) 도형크기변경 - Protected Method void onresize(float width, float height) callback method ShapeDrawable ShapeDrawable 클래스는 java.lang.object 하위의 android.graphics.drawable.drawable 클래스를상속한다. 직접하위클래스는 PaintDrawable 이다. Drawable 클래스는기본도 형을그리는반면 ShapeDrawable 클래스는 Shape 객체를받아서화면에도형을그린다. Shape가주어지지않으면 ShapeDrawable 은디폴트로서 RectShape 를그린다. 2 차원그래픽을동적으로그리기위해서는, ShapeDrawable 객체가적합하다. ShapeDrawable 을사용하면기본도형을구성할수있고도형의속성을변경할수있다. View의배경으로는 setbackgrounddrawable() 을사용할수있다. 다음은 View를확장하 여 ShapeDrawable 에그림을그리는코드이다. 예제안드로이드소스코드 public class CustomDrawableView extends View { private ShapeDrawable mdrawable;

74 public CustomDrawableView(Context context) { super(context); int x = 100; int y = 100; int width = 600; int height = 1000; mdrawable = new ShapeDrawable(new OvalShape()); mdrawable.getpaint().setcolor(0xff74ac23); mdrawable.setbounds(x, y, x+width, y+height); protected void ondraw(canvas canvas) { mdrawable.draw(canvas); 생성자를보면, ShapeDrawable에는 OvalShape 가정의되어있다. 또한도형의 color와도 bound 가정의되어있다. 도형의 color 가정의되어있지않으면디폴트(default) 로서검은색 으로지정되고, bound 가정의되지않으면도형은그려지지않는다. 정의된 CustomDrawableView 는다음과같이프로그램에서사용하여그림을그릴수있다. CustomDrawableView mcustomdrawableview; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mcustomdrawableview = new CustomDrawableView(this); setcontentview(mcustomdrawableview); 다음은 ShapeDrawable 클래스의메소드에대한설명이다. - 내포클래스 class ShapeDrawable.ShapeFactory 기반클래스는 shape factory 객체를정의한다. - XML 속성 Attribute Name Related Method Description android:bottom 아래부분 padding android:color Shape의색상정의 android:height Shape의높이정의 android:left 왼쪽 padding android:right 오른쪽 padding android:top 상단부분 padding android:width Shape의폭정의 - Public constructor

75 ShapeDrawable() ShapeDrawable 생성자 ShapeDrawable(Shape s) 지정된 Shape로 ShapeDrawable 생성 - Public Method void draw(canvas canvas) Canvas에도형을그린다 int getchangingconfiguration() Configuration 인자의 mask 반환 Drawable. ConstantState getconstantstate() int getintrinsicheight() 객체높이반환 int getintrinsicwidth() 객체넓이반환 int getopacity() 객체의투명성/ 반투명성반환 boolean getpadding(rect padding) Padding 반환 Paint getpaint() 도형을그리는 Paint 반환 ShapeDrawable. getshaderfactory() ShapeDrawable의 ShaderFactory 반환 ShaderFactory Shape getshape() ShapeDrawable의 Shape 반환 void inflate(resources r, XmlPullParser parser, AttributeSet attrs) Drawable mutate() 현재의 mutable을 drawable로반환 void setalpha(int alpha) 현재 drawable의 alpha 레벨 void setcolorfilter(colorfilter cf) 현재 drawable에 colorfilter 설정 void setdither(boolean dither) Dither 기능활성화 void getintrinsicheight() Shape의높이설정 void getintrinsicwidth() Shape의넓이설정 void setpadding(int left, int top, int right, int bottom) Shape의 padding 설정 void setpadding(rect padding) Rect 객체의 padding 설정, void setshaderfactory(shapedra ShaderFactory 설정 wable.shaderfactory fact) void setshape(shape s) 현재 ShapeDrawable의 Shape 설정 - Protected Method boolean inflatetag(string n, Resources r, XmlPullParser p, AttributeSet a) void onboundschange(rect bounds) void ondraw(shape s, Canvas c, Paint p) 하위클래스는 override하여커스텀 서브엘리먼트를파싱한다서브클래스에서 override하여객체 모양을바꾼다. Drawable의 draw() 로부터호출되어 좌표 (0,0) 에 Shape 를그린다

76 ImageView ImageView는 android.view.view 의서브클래스이다. Icon과같은이미지를출력하는데 사용된다. ImageView 클래스는자원그리고 content provider에서이미지들을가져올수 있다. Layout 관리자와연계되어사용되며확장이나착색( 틴팅, tinting) 기능도제공한다 Bitmap java.lang.object 의서브클래스이다. Bitmap 이미지를생성하고관리하는기능을제공한다. Canvas 객체가실제로그림을그리는객체이다

77 12.2 예제안드로이드프로그램과결과 다음은안드로이드예제프로그램소스코드와실행결과이다 XML 파일로직사각형을그리는프로그램. 초록색직사각형을 import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.imageview; res/drawable/green_rect.xml 로정의하여사용하였다. public class Rectangle extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); ImageView iview=(imageview)findviewbyid(r.id.imageview1); iview.setimageresource(r.drawable.green_rect); res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" android:text="@string/hello" /> <ImageView android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minheight="100px" android:minwidth="60px" android:layout_margin="115px" /> </LinearLayout> res/drawable/green_rect.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android=" android:shape="rectangle"> <solid android:color="#0f0" android:width="5dp" android:height="20dp" /> </shape>

78 ( 그림 ) 안드로이드코드에서직사각형을그리는프로그램. ShapeDrawable 클래스를사용하여빨간색직사각형을정의하였다. import android.app.activity; import android.graphics.color; import android.graphics.drawable.shapedrawable; import android.graphics.drawable.shapes.rectshape; import android.os.bundle; import android.widget.imageview; public class Rectangle extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); ShapeDrawable rect=new ShapeDrawable(new RectShape()); rect.getpaint().setcolor(color.magenta); rect.setintrinsicheight(200); rect.setintrinsicwidth(400); ImageView iview=(imageview)findviewbyid(r.id.imageview1); iview.setimagedrawable(rect); res/layout/main.xml

79 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:minheight="100px" android:minwidth="60px" android:layout_margin="115px" /> </LinearLayout> ( 그림 ) 둥근모서리사각형그리는프로그램 다음은모서리가둥근사각형을그리는프로그램이다. 각형을나타낸다. 다음코드부분이모서리가둥근사 float[] outerradii=new float[] {6,6,6,6,6,6,6,6; RectF insetrectangle=new RectF(2,2,2,2); float[] innerradii=new float[] {6,6,6,6,6,6,6,6;

80 import android.app.activity; import android.os.bundle; import android.graphics.rectf; import android.graphics.color; import android.graphics.drawable.shapedrawable; import android.graphics.drawable.shapes.roundrectshape; import android.widget.imageview; public class RoundArcRect extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); float[] outerradii=new float[] {6,6,6,6,6,6,6,6; RectF insetrectangle=new RectF(2,2,2,2); float[] innerradii=new float[] {6,6,6,6,6,6,6,6; ShapeDrawable rndrect=new ShapeDrawable (new RoundRectShape( outerradii, insetrectangle, innerradii)); rndrect.setintrinsicheight(50); rndrect.setintrinsicwidth(100); rndrect.getpaint().setcolor(color.white); ImageView iview=(imageview)findviewbyid(r.id.imageview1); iview.setimagedrawable(rndrect); res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" android:text="@string/hello" /> <ImageView android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minheight="100px" android:minwidth="100px" android:layout_margin="115px" /> </LinearLayout>

81 ( 그림 ) 텍스트와폰트프로그램 다음은텍스와폰트에대한예제프로그램이다. import android.app.activity; import android.os.bundle; import android.content.*; import android.view.*; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.typeface; public class TxtFont extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new TxFont(this)); class TxFont extends View { /** Called when the activity is first created. */ public TxFont(Context context) { super(context);

82 protected void ondraw(canvas canvas) { canvas.drawcolor(color.white); Paint tpaint=new Paint(Paint.ANTI_ALIAS_FLAG); Typeface ttype1 = Typeface.create(Typeface.SERIF, Typeface.ITALIC); tpaint.settextsize(15); tpaint.settypeface(ttype1); canvas.drawtext("serif Italic Typeface", 20, 20, tpaint); Typeface ttype2 = Typeface.create(Typeface.SANS_SERIF, Tpeface.NORMAL); tpaint.settextsize(20); tpaint.settypeface(ttype2); canvas.drawtext("sans_serif Normal Typeface", 30, 50, tpaint); ( 그림 ) 별을그린경로객체프로그램 import android.app.activity; import android.os.bundle; import android.graphics.color; import android.graphics.path; import android.graphics.drawable.shapedrawable; import android.graphics.drawable.shapes.pathshape; import android.widget.imageview; public class Stella extends Activity { /** Called when the activity is first created. */

83 public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Path p = new Path(); p.moveto(50, 0); //1 p.lineto(25, 200); //2 p.lineto(100, 50); //3 p.lineto(0, 50); //4 p.lineto(75, 200); //5 p.lineto(50, 0); //6 ShapeDrawable stella=new ShapeDrawable(new PathShape(p, 100, 100)); stella.setintrinsicheight(50); stella.setintrinsicwidth(100); stella.getpaint().setcolor(color.magenta); ImageView iview=(imageview)findviewbyid(r.id.imageview1); iview.setimagedrawable(stella); res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" android:text="@string/hello" /> <ImageView android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minheight="300px" android:minwidth="400px" android:layout_margin="80px" /> </LinearLayout>

84 ( 그림 ) Bitmap 이미지출력프로그램 다음은 Bitmap 이미지출력프로그램이다. 하나의이미지를확대하여다시나타냈다. import android.app.activity; import android.os.bundle; import android.content.*; import android.view.*; import android.graphics.canvas; import android.graphics.color; import android.graphics.bitmap; import android.graphics.bitmapfactory; public class Bitmp extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new Btmp(this)); class Btmp extends View { /** Called when the activity is first created. */ public Btmp(Context context) { super(context); protected void ondraw(canvas canvas) {

85 canvas.drawcolor(color.white); Bitmap pic1=bitmapfactory.decoderesource(getresources(), R.drawable.icon); canvas.drawbitmap(pic1, 130, 60, null); Bitmap pic2=bitmap.createscaledbitmap(pic1, 200, 200, false); canvas.drawbitmap(pic2, 60, 150, null); ( 그림 ) 방사형그래디언트프로그램 다음은방사형그래디언트프로그램이다. import android.app.activity; import android.os.bundle; import android.content.*; import android.view.*; import android.graphics.canvas; import android.graphics.color; import android.graphics.radialgradient; import android.graphics.paint; import android.graphics.shader; public class RadGradient extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) {

86 super.oncreate(savedinstancestate); // setcontentview(r.layout.main); setcontentview(new RGradient(this)); class RGradient extends View { /** Called when the activity is first created. */ public RGradient(Context context) { super(context); protected void ondraw(canvas canvas) { canvas.drawcolor(color.black); Paint circlepaint=new Paint(Paint.ANTI_ALIAS_FLAG); RadialGradient radgrad = new RadialGradient(canvas.getWidth()/2, canvas.getheight()/3, 50, Color.RED, Color.GREEN, Shader.TileMode.MIRROR); circlepaint.setshader(radgrad); canvas.drawcircle (canvas.getwidth()/2, canvas.getheight()/3, canvas.getwidth()/4, circlepaint); ( 그림 ) 스윕그래디언트프로그램 다음스윕(sweep) 그래디언트프로그램이다. import android.app.activity;

87 import android.os.bundle; import android.content.*; import android.view.*; import android.graphics.canvas; import android.graphics.color; import android.graphics.sweepgradient; import android.graphics.paint; import android.graphics.shader; public class SwpGradient extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new SwGradient(this)); class SwGradient extends View { /** Called when the activity is first created. */ public SwGradient(Context context) { super(context); protected void ondraw(canvas canvas) { canvas.drawcolor(color.black); Paint circlepaint=new Paint(Paint.ANTI_ALIAS_FLAG); SweepGradient radgrad = new SweepGradient (canvas.getwidth()/2, canvas.getheight()/3, new int[] {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.MAGENTA, null); circlepaint.setshader(radgrad); canvas.drawcircle(canvas.getwidth()/2, canvas.getheight()/3, canvas.getwidth()/4, circlepaint); ( 그림 )

88 12.3 애니매이션 프레임 (frame) 애니메이션 프레임애니메이션은전통적인의미의애니메이션으로서약간씩다른몇개의영상을연 속적으로실행하여구현한다. AnimationDrawable 클래스가프레임애니메이션의기본클 래스이다. 프레임애니메이션은 AnimationDrawable API를사용하여안드로이드 Java 코드 에서수행할수도있고, XML 파일에서수행할수도있다. XML 파일은 res/anim/ 디렉토 리에저장된다. XML 파일은 <animation-list> 요소를루트요소로그리고 <item> 요소들 을하위자식노드로구성된다. 다음은프레임애니메이션을위한 XML 파일이다. <animation-list xmlns:android=" android:oneshot="true'> <item android:duration="200" /> <item android:duration="200" /> <item android:duration="200" /> </animation-list> 이애니메이션은세개의프레임을사용하여실행된다. 만약 android:oneshot 속성을 true 로한다면애니메이션은한번실행되고마지막프레임에서멈춘다. 만약 android:oneshot 속성을 false 로하면애니메이션은계속실행된다. 다음은 rocket_thrust.xml을프레임애니 메이션으로구현한안드로이드 Java 소스코드의예를보여준다. AnimationDrawable rocketanimation; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); ImageView rocketimage = (ImageView) findviewbyid(r.id.rocket_image); rocketimage.setbackgoundresource(r.anim.rocket_thrust); rocketanimation = (AnimationDrawable) rocketimage.getbackground(); public boolean ontouchevent(motionevent event) { if (event.getaction() == MotionEvent.ACTION_DOWN) { rocketanimation.start(); return true; return super.ontouchevent(event); 이코드에서주의할부분은 AnimationDrawable 에서사용된 start() 메소드는 oncreate() 메소드에서는호출될수없다는것이다. 왜냐하면, AnimationDrawable이아직윈도우에완

89 전히밀착되지못했기때문이다. 애니메이션을바로실행하기위해서는, start() 메소드를 onwindowfocuschanged() 에서호출하여야한다 트윈 (tween) 애니메이션 트윈애니메이션은 View 객체에대하여간단한변환( 이동, 확장, 회전등) 을계속수행하 는애니메이션을의미한다. 만약 TextView 객체가있으면, 이객체를이동, 회전, 확대, 혹 은축소하는애니메이션을의미한다. 만약에배경이미지가있으면, 배경이미지도텍스트 와함께변환된다. android.view.animation 패키지는트윈애니메이션과관련된모든클래 스를제공한다. 트윈애니메이션은 XML 코드에의하여정의될수도있고안드로이드코드에의하여정 의될수도있다. 일반적으로 Layout을정의할때처럼 XML 파일로트윈애니메이션을정의 하는것을권장한다. 왜냐하면 XML 파일로정의하면, 더읽기쉽고재사용도쉽기때문이 다. 아래의예에서는 XML 을사용한다. 애니메이션 XML 파일은 res/anim/ 디렉토리에저장된다. 애니메이션파일은오직하나 의루트(root) 요소를가지고있어야한다. 이루트요소는 <alpha>, <scale>, <translate>, <rotate>, <interpolate element>, <set> 요소이다. <set> 요소는다른요소를원소로가 지는그룹요소이다. 디폴트로서, 모든애니메이션은명령과동시에실행된다. 명령을순차 적으로실행하려면, startoffset 속성을설정하여야한다. 다음 XML 파일은 ApiDemo 예로서 View 객체를확장하고회전시킨다. <set android:shareinterpolator = "false"> <scale android:interpolator ="@android;anim/accelerate_decelerate_interpolator" android:fromxscale = "1.0" android:toxscale = "1.4" android:fromyscale = "1.0" android:toyscale = "0.6" android:pivotx = "50%" android:pivoty = "50%" android:fillafter = "false" android:duration = "700"/> <set android:interpolator = "@android:anim/decelerate_interpolator"> <scale android:fromxscale = "1.4" android:toxscale = "0.0" android:fromyscale = "0.6" android:toyscale = "0.0" android:pivotx = "50%" android:pivoty = "50%" android:startoffset = "700" android:duration = "400" android:fillbefore ="false" /> <rotate android:fromdegrees = "0" android:todegrees = "-45" android:toyscale = "0.0" android:pivotx = "50%"

90 </set> </set> android:pivoty = "50%" android:startoffset = "700" android:duration = "400" /> pivotx 값은객체자체혹은상위부모객체에대하여상대적으로설정될수있다. 그러나 알맞은포맷을사용하여야한다. 예를들어, 50 은상위부모에대하여 50% 상대적이라는 의미이고, 50% 은객체자체에대하여 50% 상대적이라는의미이다. 2차원객체의변환이시간에따라서어떻게적용되는가는 Interpolator 객체를통하여 조정할수있다. 안드로이드는스피드커브를조정하는몇개의 interpolator 서브클래스를 포함하고있다. 예를들어 AccelerateInterpolator 는변환의속도를처음에는천천히시작 하여점점빠르게조정한다. 예를들어서, 다음 hyperspace_jump.xml XML 파일이 res/anim/ 폴더에있다면, 안드로이드 Java 코드는이파일을참조하여 ImageView 객체에 적용할수있다. ImageView spaceshipimage = (Image) findviewbyid(r.id.spaceshipimage); Animation hyperspacejumpanimation = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump); spaceshipimage.startanimation(hyperspacejumpanimation); startanimation() 에대한대안으로서, 애니메이션시작시간을 Animation.setStartTime() 으 로설정할수있다. 다음에애니메이션을 View에 View.setAnimation() 으로설정할수있 다 애니메이션클래스 Animation 클래스는 android.view.animation.animation이며 java.lang.object를상속한 다. 관련된하위클래스는 AlphaAnimation, AnimationSet, RotateAnimation, ScaleAnimation, TranslateAnimation 이다. 애니메이션클래스는 View, Surface, 그리고 다른객체에적용된다. - 내포클래스 인터페이스 Animation.AnimationListener Notification을받는다 클래스 Animation.Description 크기를파싱하는유틸리티클래스 - XML 속성 속성이름 관련된메소드 설명 android:detachwallpaper setdetachwallpaper(boolean) 윈도우애니메이션옵션 android:duration setduration(long) 애니메이션수행시간 android:fillafter setfillafter(boolean) True 이면, 애니메이션완료후애니메이션변환적용

91 android:fillbefore setfillbefore(boolean) True 이면, 애니메이션완료전애니메이션변환적용 android:fillenabled setfillenabled(boolean) True 이면, fillafter 적용 android:interpolator setinterpolator(interpolator) 애니메이션보간적용 android:repeatcount setrepeatcount(int) 애니메이션반복회수 android:repeatmode setrepeatmode(int) 애니메이션행동정의 android:startoffset setstartoffset(long) 애니메이션수행지연시간정의( 밀리세컨드) android:zadjustment setzadjustment(int) 애니메이션 Z 순서조정 - 상수 int ABSOLUTE 픽셀개수 int INFINITE 애니메이션무한실행 int RELATIVE_TO_PARENT 부동소수점수로서현재객체의부모객체의폭혹은높이와곱해진다. int RELATIVE_TO_SELF 부동소수점수로서현재의애니메이션객체의폭혹은높이와곱해진다. int RESTART 애니메이션이마지막에도달하고 INFINITE_REPEAT 이거나양수면애니메이션은처음부터시작 int REVERSE 애니메이션이마지막에도달하고 INFINITE_REPEAT 이거나양수면애니메이션은역방향으로진행 int START_ON_FIRST_FRAME 애니메이션시작시간 int ZORDER_BOTTOM 애니메이션 Z 순서의영향을 받도록조정 int ZORDER_NORMAL 애니메이션이현재 Z 순서로 유지되도록한다 int ZORDER_TOP 애니메이션이다른내용의 최상위가되도록한다. - Public Constructors Animation( ) Animation(Context context, AttributeSet attrs) 디폴트값을사용하여새로운애니메이션생성 context, attrs 인자로새로운애니메이션생성 - Public Method long boolean long boolean boolean interpolator computedurationhint() getdetachwallpaper() getduration() getfillafter() getfillbefore() getinterpolator()

92 int getrepeatcount() int getrepeatmode() long getstartoffset() long getstarttime() boolean gettransformation(long currenttime, Transformation outtransformation) int getzadjustment() boolean hasended() boolean hasstarted() void initialize(int width, int height, int parentwidth, int parentheight) boolean isfillenabled() boolean isinitialized() void reset() void restrictduration(long durationmillis) void scalecurrentduration(float scale) void setanimationlistener(animation.animationlistene r listener) void setdetachwallpaper(boolean detachwallpaper) void setduration(long durationmillis) void setfillafter(boolean fillafter) void setfillbefore(boolean fillbefore) void setfillenabled(boolean fillenabled) void setinterpolator(context context, int resid) void setinterpolator(interpolator i) void setrepeatcount(int repeatcount) void setrepeatmode(int repeatmode) void setstartoffset(long starttimemillis) void setstarttime(long starttimemillis) void setzadjustment(int zadjustment) void start() void startnow() boolean willchangebounds() boolean willchangetransformation(int type, float value, int size, int parentsize) - Protected method void applytransformation(float interpolationtime, Tran sformation t) Animation clone() void ensureinterpolator() void resolvesize(int type, float value, int size, int parentsize)

93 12.4 예제애니메이션프로그램과결과 프레임애니메이션 다음은프레임애니메이션프로그램과실행결과이다. import android.app.activity; import android.graphics.drawable.animationdrawable; import android.graphics.drawable.bitmapdrawable; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.imageview; public class FrameAnimation extends Activity { AnimationDrawable frameanimation = null; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.frame); // Handle 시작버튼 final Button onbutton = (Button) findviewbyid(r.id.buttonstart); onbutton.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { startanimation(); ); // Handle 중지버튼 final Button offbutton = (Button) findviewbyid(r.id.buttonstop); offbutton.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { stopanimation(); ); private void startanimation() { ImageView img = (ImageView)findViewById(R.id.ImageView1); // Three frames for frame animation BitmapDrawable frame1 = (BitmapDrawable)getResources().getDrawable(R.drawable.f1); BitmapDrawable frame2 = (BitmapDrawable)getResources().getDrawable(R.drawable.f2); BitmapDrawable frame3 = (BitmapDrawable)getResources().getDrawable(R.drawable.f3); // Get the background int Duration = 50; frameanimation = new AnimationDrawable(); frameanimation.setoneshot(false); // loop continuously

94 frameanimation.addframe(frame1, Duration); frameanimation.addframe(frame2, Duration); frameanimation.addframe(frame3, Duration); img.setbackgrounddrawable(frameanimation); frameanimation.setvisible(true,true); frameanimation.start(); private void stopanimation() { frameanimation.stop(); frameanimation.setvisible(false,false); res/layout/frame.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/buttonrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/buttonstart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 시작" /> <Button android:id="@+id/buttonstop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 끝" /> </LinearLayout> <ImageView android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> res/drawable f1.bmp, f2.bmp, f3.bmp ( 그림 )

95 트윈애니메이션 다음은트윈애니메이션프로그램과결과이다. import android.app.activity; import android.os.bundle; import android.view.view; import android.view.animation.animation; import android.view.animation.animationutils; import android.widget.button; import android.widget.imageview; public class TweenAni extends Activity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.tween); // Handle Scale Button final Button growbutton = (Button) findviewbyid(r.id.buttonscale); growbutton.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { performanimation(r.anim.scale); ); // Handle Move Button final Button movebutton = (Button) findviewbyid(r.id.buttontranslate); movebutton.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { performanimation(r.anim.translate); ); // Handle Spin Button final Button spinbutton = (Button) findviewbyid(r.id.buttonrotate); spinbutton.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { performanimation(r.anim.rotate); ); private void performanimation(int animationresourceid) { // We will animate the imageview ImageView reusableimageview = (ImageView)findViewById(R.id.ImageViewForTweening); reusableimageview.setimageresource(r.drawable.green_rect); reusableimageview.setvisibility(view.visible); // Load the appropriate animation Animation an = AnimationUtils.loadAnimation(this, animationresourceid); // Register a listener, so we can disable and re-enable buttons an.setanimationlistener(new MyAnimationListener()); // Start the animation reusableimageview.startanimation(an);

96 private void togglebuttons(boolean clickablestate) { // Handle Scale Button final Button growbutton = (Button) findviewbyid(r.id.buttonscale); growbutton.setclickable(clickablestate); // Handle Move Button final Button movebutton = (Button) findviewbyid(r.id.buttontranslate); movebutton.setclickable(clickablestate); // Handle Spin Button final Button spinbutton = (Button) findviewbyid(r.id.buttonrotate); spinbutton.setclickable(clickablestate); class MyAnimationListener implements Animation.AnimationListener { public void onanimationend(animation animation) { // Hide our ImageView ImageView reusableimageview = (ImageView)findViewById(R.id.ImageViewForTweening); reusableimageview.setvisibility(view.invisible); // Enable all buttons once animation is over togglebuttons(true); public void onanimationrepeat(animation animation) { // what to do when animation loops public void onanimationstart(animation animation) { // Disable all buttons while animation is running togglebuttons(false); res/layout/tween.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" android:text="@string/tween" /> <LinearLayout android:id="@+id/buttonrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/buttonscale" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 성장"></Button> <Button

97 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 이동"></Button> android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 회전"></Button> </LinearLayout> <LinearLayout android:layout_height="fill_parent" android:orientation="horizontal" android:layout_gravity="center_vertical center_horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:minheight="90px" android:minwidth="90px" android:layout_margin="115px"></imageview> </LinearLayout> </LinearLayout> res/anim/scale.xml <?xml version="1.0" encoding="utf-8"?> <!-- Over the course of 5 seconds, scale up and back --> <set xmlns:android=" android:shareinterpolator="false"> <scale android:pivotx="50%" android:pivoty="50%" android:fromxscale="1.0" android:fromyscale="1.0" android:toxscale="4.0" android:toyscale="4.0" android:duration="3000" /> <scale android:startoffset="2500" android:duration="3000" android:pivotx="50%" android:pivoty="50%" android:fromxscale="1.0" android:fromyscale="1.0" android:toxscale="0.5" android:toyscale="0.5" /> </set> res/anim/rotate.xml <?xml version="1.0" encoding="utf-8"?> <!-- Over the course of 5 seconds, spin > <set xmlns:android=" android:shareinterpolator="false"> <rotate android:fromdegrees="0" android:todegrees="700"

98 </set> android:pivotx="50%" android:pivoty="50%" android:duration="10000" /> res/anim/translate.xml <?xml version="1.0" encoding="utf-8"?> <!-- Over the course of 5 seconds, move 150 up and then 100 back down the Y axis. --> <set xmlns:android=" android:shareinterpolator="false"> </set> <translate android:toydelta="-100" android:fillafter="true" android:duration="2500" /> <translate android:toydelta="150" android:fillafter="true" android:duration="2500" android:startoffset="2500"/> ( 그림 )

99 13 장. 위치기반서비스 (Location-Based Service) 위치기반서비스는모바일사용자들에게필수적인것이다. 위치기반서비스는 android.location 패키지와 Google Maps 외부라이브러리를통하여제공된다. 위치기반 서비스에서가장중요한시스템서비스는 LocationManager 이며위치기반서비스를위한 API 를제공한다. 다른시스템서비스와마찬가지로 LocationManager 를직접객체화하는 것이아니라 getsystemservice(context.location_service) 호출을통하여 LocationManager 객체를얻는다. LocationManager 객체를얻으면다음 3가지기능을할 수있다. - LocationManager 로부터가장최근의위치정보를제공하는 LocationProvider 를구한다. - LocationProvider 로부터현재위치정보의제공을등록(register)/ 해제(unregister) 한다. - 모바일기기가정해진위도와경도범위에들어오면위치정보 Intent를작동시킬수 있도록등록(register)/ 해제(unregister) 한다. 그러나 AVD를통하여위치기반서비스를개발하는경우에는실제로 GPS로부터위도와 경도정보를받지는못한다. 이런경우에는 DDMS(Dalvik Debug Monitoring Service) 에서 위도와경도정보를입력할수있다. 위도와경도정보를입력하는방법에는 3가지방법이 있다. - 키보드에서입력하는방법 - GPX 파일을통하여입력하는방법 - KML 파일을통하여입력하는방법 간단한응용의경우에는키보드를통하여입력하는방법을사용하는것이편리하다. DDMS 에는디폴트값으로이미위도(latitude): , 경도(longitude): 값이입 력되어있다 간단한위치기반서비스프로그램 다음은간단한위치기반응용프로그램이다. 첫번째코드는안드로이드 Java 코드이다. 이프로그램은 LocationManager를얻은다음에 List<String> providers = locationmanager.getproviders(true); 에의하여위치정보제공자를얻는다. 위치정보제 공자로부터위도와경도정보를얻어서화면에출력한다. import java.util.list; import android.app.activity; import android.os.bundle; import android.content.context; import android.location.location; import android.location.locationmanager; import android.location.locationlistener; import android.widget.textview;

100 public class BasicLoc extends Activity { /** Called when the activity is first created. */ LocationManager locationmanager; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); locationmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); locproviders(); public void locproviders() { TextView tvw = (TextView)findViewById(R.id.myTextView); StringBuilder sb = new StringBuilder(" 위치정보공급자: "); List<String> providers = locationmanager.getproviders(true); for(string provider : providers) { locationmanager.requestlocationupdates (provider, 1000, 0, new LocationListener() { public void onlocationchanged(location location) { public void onproviderdisabled(string provider) { public void onproviderenabled(string provider) { public void onstatuschanged (String provider, int status, Bundle extras) { ); sb.append(provider).append("\n"); Location location = locationmanager.getlastknownlocation(provider); if(location!= null) { double lat = location.getlatitude(); // 위도 double lng = location.getlongitude(); // 경도 sb.append(" 위치(").append(" 위도:").append(lat).append(", 경도:"). append(lng).append(")"); else { sb.append(" 위치를찾을수없음"); tvw.settext(sb); 다음은 res/layout/ 폴더에있는 main.xml 파일의내용이다. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:id="@+id/mytextview" android:layout_height="wrap_content" android:text="@string/hello"

101 /> </LinearLayout> 다음은 AndroidManifest.xml 파일의내용이다. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="com.lbs1" android:versioncode="1" android:versionname="1.0"> <application <activity android:name=".location1" <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.access_fine_location"/> <uses-sdk android:minsdkversion="7" /> </manifest> 출력결과는다음과같다. ( 그림 )

102 13.2 요구기준에의한위치찾기예제프로그램 다음은요구기준에의하여위치정보를찾는프로그램이다. 다음코드부분이요구하는 위치정보는넓은(coarse) 간격의위치정보이다. 정밀한간격을요구하는경우에는 (Criteria.ACCURACY_FINE) 이라고해야한다. Criteria criteria = new Criteria(); criteria.setaccuracy(criteria.accuracy_coarse); criteria.setaltituderequired(false); criteria.setbearingrequired(false); criteria.setcostallowed(true); criteria.setpowerrequirement(criteria.power_low); 다음은프로그램소스코드이다. 위치정보갱신이가능하도록되어있으며다음코드 locationmanager.requestlocationupdates(provider, 2000, 10, locationlistener); 에의하여 2 초마다위치정보를갱신한다. import android.app.activity; import android.os.bundle; import android.content.context; import android.location.criteria; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.widget.textview; public class criteria_loc extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); LocationManager locationmanager; locationmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setaccuracy(criteria.accuracy_coarse); criteria.setaltituderequired(false); criteria.setbearingrequired(false); criteria.setcostallowed(true); criteria.setpowerrequirement(criteria.power_low); String provider = locationmanager.getbestprovider(criteria, true); Location location = locationmanager.getlastknownlocation(provider); updatewithnewlocation(location); locationmanager.requestlocationupdates(provider, 2000, 10, locationlistener);

103 private final LocationListener locationlistener = new LocationListener() { public void onlocationchanged(location location) { updatewithnewlocation(location); public void onproviderdisabled(string provider){ updatewithnewlocation(null); public void onproviderenabled(string provider){ public void onstatuschanged(string provider, int status, Bundle extras) { ; /** Update UI with a new location */ private void updatewithnewlocation(location location) { TextView MyLocationText = (TextView)findViewById(R.id.MyLocationText); String latlongstring; if (location!= null) { double lat = location.getlatitude(); double lng = location.getlongitude(); latlongstring = " 위도:" + lat + ", 경도:" + lng; else { latlongstring = " 위치찾지못함."; MyLocationText.setText(" 당신의현재위치는:\n" + latlongstring); 다음은 res/layout/ 폴더에있는 main.xml 파일의내용이다. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" /> <TextView android:id="@+id/mylocationtext" android:layout_height="fill_parent" android:text="@string/hello" /> </LinearLayout> 다음은 AndroidManifest.xml 파일의내용이다. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="

104 package="com.wai2" android:versioncode="1" android:versionname="1.0"> <application <activity android:name=".wai2" <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.access_fine_location"/> <uses-sdk android:minsdkversion="7" /> </manifest> 다음은출력결과이다. ( 그림 )

105 13.3 지오코더 (Geocoder) 에의한주소생성 다음은위도와경도정보로부터주소를출력하는프로그램이다. 다음코드부분에서 Geocoder gc = new Geocoder(this, Locale.getDefault()); 위도와경도정보로부터주소를반환하는 Geocoder 객체를얻고, 다음코드부분에서 List<Address> addresses = gc.getfromlocation(lat, lng, 1); 실제주소를얻는다. import java.io.ioexception; import java.util.list; import java.util.locale; import android.app.activity; import android.os.bundle; import android.content.context; import android.location.address; import android.location.criteria; import android.location.geocoder; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.widget.textview; public class GeoLoc extends Activity { public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); LocationManager locationmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setaccuracy(criteria.accuracy_fine); criteria.setaltituderequired(false); criteria.setbearingrequired(false); criteria.setcostallowed(true); criteria.setpowerrequirement(criteria.power_low); String provider = locationmanager.getbestprovider(criteria, true); Location location = locationmanager.getlastknownlocation(provider); updatewithnewlocation(location); locationmanager.requestlocationupdates(provider, 2000, 10, locationlistener);

106 private final LocationListener locationlistener = new LocationListener() { public void onlocationchanged(location location) { updatewithnewlocation(location); public void onproviderdisabled(string provider){ updatewithnewlocation(null); public void onproviderenabled(string provider) { public void onstatuschanged(string provider, int status, Bundle extras){ ; /** Update UI with a new location */ private void updatewithnewlocation(location location) { TextView MyLocationText = (TextView)findViewById(R.id.MyLocationText); String latlongstring; String addressstring = null; if (location!= null) { double lat = location.getlatitude(); double lng = location.getlongitude(); latlongstring = "( 위도:" + lat + ", 경도:" + lng + ")"; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getfromlocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getmaxaddresslineindex(); i++) sb.append(address.getaddressline(i)).append("\n"); sb.append(address.getlocality()).append("\n"); sb.append(address.getpostalcode()).append("\n"); sb.append(address.getcountryname()); addressstring = sb.tostring(); else addressstring = " 주소찾을수없음."; catch (IOException e) {System.out.println("IO Exception occurred.\n"); else { latlongstring = " 위치발견되지않음."; MyLocationText.setText(" 당신의위치:\n" + latlongstring + "\n\n 당신의주소:\n" + addressstring); AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="com.geoloc" android:versioncode="1" android:versionname="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name">

107 <activity android:name=".geoloc" <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.access_fine_location"/> <uses-sdk android:minsdkversion="7" /> </manifest> res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:layout_height="wrap_content" /> <TextView android:layout_height="fill_parent" /> </LinearLayout> 다음은출력결과이다. ( 그림 )

108 13.4 MapView 와 MapActivity 에의한지도출력 다음은 MapView와 MapActivity 에의한지도출력프로그램이다. 다음코드는응용을위한 MapView와 mapcontroller 를선언하는부분이다. MapView mymapview = (MapView)findViewById(R.id.myMapView); mapcontroller = mymapview.getcontroller(); 다음코드는지도출력옵션을나타내는코드이다. // Configure the map display options mymapview.setsatellite(true); mymapview.setstreetview(true); mymapview.displayzoomcontrols(false); 다음코드는지도를갱신하는부분이다. // Update the map location. Double geolat = location.getlatitude()*1e6; Double geolng = location.getlongitude()*1e6; GeoPoint point = new GeoPoint(geoLat.intValue(), geolng.intvalue()); mapcontroller.animateto(point); 다음은전체코드이다. import java.io.ioexception; import java.util.list; import java.util.locale; import android.location.address; import android.location.geocoder; import android.os.bundle; import com.google.android.maps.geopoint; import com.google.android.maps.mapactivity; import com.google.android.maps.mapcontroller; import com.google.android.maps.mapview; import android.content.context; import android.location.criteria; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.widget.textview; public class MyMapActivity extends MapActivity { MapController mapcontroller; public void oncreate(bundle icicle) { super.oncreate(icicle);

109 setcontentview(r.layout.main); MapView mymapview = (MapView)findViewById(R.id.myMapView); mapcontroller = mymapview.getcontroller(); // Configure the map display options mymapview.setsatellite(true); mymapview.setstreetview(true); mymapview.displayzoomcontrols(false); // Zoom in mapcontroller.setzoom(17); LocationManager locationmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setaccuracy(criteria.accuracy_fine); criteria.setaltituderequired(false); criteria.setbearingrequired(false); criteria.setcostallowed(true); criteria.setpowerrequirement(criteria.power_low); String provider = locationmanager.getbestprovider(criteria, true); Location location = locationmanager.getlastknownlocation(provider); updatewithnewlocation(location); locationmanager.requestlocationupdates(provider, 2000, 10, locationlistener); ; private final LocationListener locationlistener = new LocationListener() { public void onlocationchanged(location location) { updatewithnewlocation(location); public void onproviderdisabled(string provider) { updatewithnewlocation(null); public void onproviderenabled(string provider) { public void onstatuschanged(string provider, int status, Bundle extras) { /** Update the map with a new location */ private void updatewithnewlocation(location location) { // Update the map location. Double geolat = location.getlatitude()*1e6; Double geolng = location.getlongitude()*1e6; GeoPoint point = new GeoPoint(geoLat.intValue(), geolng.intvalue()); mapcontroller.animateto(point); TextView mylocationtext = (TextView)findViewById(R.id.myLocationText); String latlongstring; String addressstring = " 주소발견하지못함"; if (location!= null) { double lat = location.getlatitude(); double lng = location.getlongitude(); latlongstring = " 위도:" + lat + "\n 경도:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try {

110 List<Address> addresses = gc.getfromlocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getmaxaddresslineindex(); i++) sb.append(address.getaddressline(i)).append("\n"); sb.append(address.getlocality()).append("\n"); sb.append(address.getpostalcode()).append("\n"); sb.append(address.getcountryname()); addressstring = sb.tostring(); catch (IOException e) { else { latlongstring = " 위치찾지못했음."; mylocationtext.settext(" 당신의현재위치\n" + latlongstring + "\n\n 당신의주소:\n" + addressstring); protected boolean isroutedisplayed() { return false; 다음은 AndroidManifest.xml 코드이다. Google 지도사용을선언하는다음부분은 <activity>... </activity> 안에반드시존재하여야한다. <uses-library android:name="com.google.android.maps" /> 인터넷사용권한을부여하는다음부분도 AndroidManifest.xml 파일에반드시있어야한다. 다음은 <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_fine_location" /> XML 파일코드이다. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="com.mymapactivity" android:versioncode="1" android:versionname="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".mymapactivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps" /> </application>

111 <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-sdk android:minsdkversion="7" /> </manifest> 다음은 main.xml 코드이다. 이코드에서가장중요한부분은 <com.google.android.maps.mapview 에서 android:apikey 부분이다. 지도 Key는 MD 5 지문을생성한다음에 code.google.com/android/maps-api-signup.html에서부여받아야 한다. IP 주소마다다른 Key를부여받아야 google 지도서비스를사용할수있다. res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_height="fill_parent" > <TextView android:id="@+id/mylocationtext" android:layout_height="wrap_content" android:text="@string/hello" /> <com.google.android.maps.mapview android:id="@+id/mymapview" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apikey="0a1nyi... 생략부분... B0Dt-Q" /> </LinearLayout> 다음은출력결과이다. 위도와경도정보가출력되고주소가출력된다. 다음에지도가출력 되었다. 현재다음옵션이선언되어있다. android:enabled="true" android:clickable="true" 그래서지도를움직일수가있으며지도에클릭을할수가있다. 지도를마우스로움직이면 현재 AVD 윈도우에없는지도부분은다시로딩된다. 그리고지도를클릭하면도로에파 란색선이형성된다. 다음첫번째지도그림은원래출력된지도그림이고, 그다음그림 은지도를마우스로클릭한다음에이동시킨그림이다. 도로에파란색선이형성되어있고 민둥산이크게나타나있다

112 ( 그림 ) ( 그림 )

113 13.5 MD5 인증구하기 참고로다음은 MD5 인증서지문을구하는그림이다. ( 그림 ) MD5 를구하는절차는다음과같이하였다. 이과정이약간까다롭지만 google 지도서비 스를받기위해서는반드시필요한과정이다. 다음과정은본저자가사용한방법이다. 일 반적으로거의비슷하지만약간씩다를수는있다. 이과정을시작하기전에 에계정을먼저만들어두어야한다. (1) 편의상 C:/Program Files/Java/jre1.60_03/bin/ 밑에있는 keytool.exe 파일과 jli.dll 파일을 C:/Document and Settings/user/ 로복사한다. (2) 편의상 C:/Document and Settings/user/.android/ 밑에있는 debug.keyst ore 파일을 C:/ 밑으로복사한다. (3) 다음에 C:/Document and Settings/user/ 에있는 keytool.exe 파일을실행한다. 실행옵션은다음과같다. C:/Document and Settings/user>keytool -list -alias andro iddebugkey -keystore C:/debug.keystore -storepass android -keypass android (4) MD5 지문이출력된다. MD5 지문은두개의문자와 : 로구성된패턴으로서예를들어 7F:8F:7A:04:1E:E7:D3:E9:F7:5A:60:37:FA:1A:7B:BB 형태이다

9 차시고급위젯다루기 1 학습목표 날짜 / 시간과관련된위젯을배운다. 웹뷰를사용하여간단한웹브라우저기능을구현한다. 매니패스트파일의설정법을배운다. 2 확인해볼까? 3 날짜 / 시간위젯 1) 활동하기 활동개요

9 차시고급위젯다루기 1 학습목표 날짜 / 시간과관련된위젯을배운다. 웹뷰를사용하여간단한웹브라우저기능을구현한다. 매니패스트파일의설정법을배운다. 2 확인해볼까? 3 날짜 / 시간위젯 1) 활동하기 활동개요 9 차시고급위젯다루기 1 학습목표 날짜 / 시간과관련된위젯을배운다. 웹뷰를사용하여간단한웹브라우저기능을구현한다. 매니패스트파일의설정법을배운다. 2 확인해볼까? 3 날짜 / 시간위젯 1) 활동하기 활동개요 [ 그림 9-1] 시간예약앱 활동과정 - 2 - [ 그림 9-2] 안드로이드 SDK Manager [ 예제 9-1]main.xml 1

More information

[ 그림 8-1] XML 을이용한옵션메뉴설정방법 <menu> <item 항목ID" android:title=" 항목제목 "/> </menu> public boolean oncreateoptionsmenu(menu menu) { getme

[ 그림 8-1] XML 을이용한옵션메뉴설정방법 <menu> <item 항목ID android:title= 항목제목 /> </menu> public boolean oncreateoptionsmenu(menu menu) { getme 8 차시메뉴와대화상자 1 학습목표 안드로이드에서메뉴를작성하고사용하는방법을배운다. 안드로이드에서대화상자를만들고사용하는방법을배운다. 2 확인해볼까? 3 메뉴 1) 학습하기 [ 그림 8-1] XML 을이용한옵션메뉴설정방법 public boolean

More information

뷰그룹 ( 레이아웃 ) 레이아웃이름 ( 클래스이름 ) FrameLayout LinearLayout 설명단일객체를표현하기위한프레임. 왼쪽상단에하나의뷰를배치하기때문에나중 에그린객체만보여준다. 수평또는수직으로자손의뷰를배치. 뷰가들어갈만한공간이없을때는자동으로 스크롤바가나타난다

뷰그룹 ( 레이아웃 ) 레이아웃이름 ( 클래스이름 ) FrameLayout LinearLayout 설명단일객체를표현하기위한프레임. 왼쪽상단에하나의뷰를배치하기때문에나중 에그린객체만보여준다. 수평또는수직으로자손의뷰를배치. 뷰가들어갈만한공간이없을때는자동으로 스크롤바가나타난다 크기에사용할수있는단위 표기 단위 설명 px 픽셀수 사용중화면에서의픽셀수, 해상도가높아지면픽셀의물리적인크기가줄어든다. in 인치 사용중화면에서의인치단위의길이 mm 밀리미터 사용중화면에서의밀리미터단위의길이 pt 포인트수 사용중화면에서의 1/72 인치를 1 포인트로하는길이 dp 해상도에의존하지않는픽셀수 1은해상도가 180dpi일때 1 픽셀. 10dp가 160dpi일때에는

More information

안드로이드기본 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 -

안드로이드기본 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 - 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 - ArrayAdapter ArrayAdapter adapter = new ArrayAdapter(this, android.r.layout.simple_list_item_1,

More information

( )부록

( )부록 A ppendix 1 2010 5 21 SDK 2.2. 2.1 SDK. DevGuide SDK. 2.2 Frozen Yoghurt Froyo. Donut, Cupcake, Eclair 1. Froyo (Ginger Bread) 2010. Froyo Eclair 0.1.. 2.2. UI,... 2.2. PC 850 CPU Froyo......... 2. 2.1.

More information

어댑터뷰

어댑터뷰 04 커스텀어댑터뷰 (Custom Adapter View) 커스텀어댑터뷰 (Custom Adapter View) 커스텀어댑터뷰 (Custom Adatper View) 란? u 어댑터뷰의항목하나는단순한문자열이나이미지뿐만아니라, 임의의뷰가될수 있음 이미지뷰 u 커스텀어댑터뷰설정절차 1 2 항목을위한 XML 레이아웃정의 어댑터정의 3 어댑터를생성하고어댑터뷰객체에연결

More information

[ 그림 7-1] 프로젝트 res 폴더 이미지뷰 [ 예제 7-1] 이미지뷰 1 <LinearLayout 2 ~~~~ 중간생략 ~~~~ 3 android:orientation="vertical" > 4 <ImageView

[ 그림 7-1] 프로젝트 res 폴더 이미지뷰 [ 예제 7-1] 이미지뷰 1 <LinearLayout 2 ~~~~ 중간생략 ~~~~ 3 android:orientation=vertical > 4 <ImageView 7 차시이미지처리 1 학습목표 이미지뷰를사용하는방법을배운다. 비트맵을사용하는방법을배운다. 2 확인해볼까? 3 이미지뷰와이미지버튼 1) 학습하기 [ 그림 7-1] 프로젝트 res 폴더 이미지뷰 [ 예제 7-1] 이미지뷰 1 4

More information

13ÀåÃß°¡ºÐ

13ÀåÃß°¡ºÐ 13 CHAPTER 13 CHAPTER 2 3 4 5 6 7 06 android:background="#ffffffff"> 07

More information

03장

03장 CHAPTER3 ( ) Gallery 67 68 CHAPTER 3 Intent ACTION_PICK URI android provier MediaStore Images Media EXTERNAL_CONTENT_URI URI SD MediaStore Intent choosepictureintent = new Intent(Intent.ACTION_PICK, ë

More information

(Microsoft PowerPoint - AndroG3\306\367\306\303\(ICB\).pptx)

(Microsoft PowerPoint - AndroG3\306\367\306\303\(ICB\).pptx) w w w. g b t e c. c o. k r 6 안드로이드 App 적용하기 115 1. 안드로이드개요 모바일 OS 의종류 - 스마트폰 : 스마트폰운영체제탑재 애플의 IOS(iPhone OS) - 아이폰, 아이패드, 아이팟터치 구글의안드로이드 - Nexus, 갤럭시 A, S, 모토로이, 시리우스,... MS 의윈도우모바일 ( 윈도우폰 7) - 옴니아 2,

More information

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android 2 xmlns:tools=http://schemas.android. 10 차시파일처리 1 학습목표 내장메모리의파일을처리하는방법을배운다. SD 카드의파일을처리하는방법을배운다. 2 확인해볼까? 3 내장메모리파일처리 1) 학습하기 [ 그림 10-1] 내장메모리를사용한파일처리 2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1

More information

학습목표 선언하여디자인을하는방법을이해하고, 실행할수있다. 시작화면을만드는방법과대체리소스를사용하는방법을이해하고실행할수있다. About 과같은상자를구현하고, 테마를적용하는법을이해하고실행할수있다.

학습목표 선언하여디자인을하는방법을이해하고, 실행할수있다. 시작화면을만드는방법과대체리소스를사용하는방법을이해하고실행할수있다. About 과같은상자를구현하고, 테마를적용하는법을이해하고실행할수있다. 헬로, 안드로이드 3 주차 사용자인터페이스디자인하기 (1) 강대기동서대학교컴퓨터정보공학부 학습목표 선언하여디자인을하는방법을이해하고, 실행할수있다. 시작화면을만드는방법과대체리소스를사용하는방법을이해하고실행할수있다. About 과같은상자를구현하고, 테마를적용하는법을이해하고실행할수있다. 차례 스도쿠예제소개하기 선언하여디자인하기 시작화면만들기 대체리소스사용하기 About

More information

Microsoft PowerPoint Android-SDK설치.HelloAndroid(1.0h).pptx

Microsoft PowerPoint Android-SDK설치.HelloAndroid(1.0h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 Eclipse (IDE) JDK Android SDK with ADT IDE: Integrated Development Environment JDK: Java Development Kit (Java SDK) ADT: Android Development Tools 2 JDK 설치 Eclipse

More information

리니어레이아웃 - 2 -

리니어레이아웃 - 2 - 4 차시레이아웃 1 학습목표 레이아웃의개념을이해한다. 중복리니어레이아웃의개념이해한다. 2 확인해볼까? 3 레이아웃개념익히기 1) 학습하기 [ 그림 4-1] ViewGroup 클래스계층도 리니어레이아웃 - 2 - [ 예제 4-1]orientation 속성-horizontal 1

More information

슬라이드 1

슬라이드 1 헬로, 안드로이드 3 주차 사용자인터페이스디자인하기 (1) 강대기동서대학교컴퓨터정보공학부 학습목표 선언하여디자인을하는방법을이해하고, 실행핛수있다. 시작화면을만드는방법과대체리소스를사용하는방법을이해하고실행핛수있다. About 과같은상자를구현하고, 테마를적용하는법을이해하고실행핛수있다. 차례 스도쿠예제소개하기 선언하여디자인하기 시작화면만들기 대체리소스사용하기 About

More information

Microsoft PowerPoint - 4주차_Android_UI구현.ppt [호환 모드]

Microsoft PowerPoint - 4주차_Android_UI구현.ppt [호환 모드] Android UI 구현 학습목표 교육목표 Android application 구성요소 Activity Layout UI 설계 Linear Layout 구현 Android application 구성요소 (1) () Application 구성요소 AndroidManifest.xml Android application 구성요소 (2) 구성요소 기능 Activity

More information

Microsoft PowerPoint SDK설치.HelloAndroid(1.5h).pptx

Microsoft PowerPoint SDK설치.HelloAndroid(1.5h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 개발환경구조및설치순서 JDK 설치 Eclipse 설치 안드로이드 SDK 설치 ADT(Androd Development Tools) 설치 AVD(Android Virtual Device) 생성 Hello Android! 2 Eclipse (IDE) JDK Android SDK with

More information

01장

01장 CHAPTER1 Camera (MediaStore) EXIF 1 2 CHAPTER 1 SDK (intent) Camera Camera Camera Android Manifest xml Camera Camera

More information

1부

1부 PART 1 2 PART 01 _ SECTION 01 API NOTE SECTION 02 3 SECTION 02 GPL Apache2 NOTE 4 PART 01 _ SECTION 03 (Proyo) 2 2 2 1 2 2 : 2 2 Dalvik JIT(Just In Time) CPU 2~5 2~3 : (Adobe Flash) (Air) : SD : : : SECTION

More information

4S 1차년도 평가 발표자료

4S 1차년도 평가 발표자료 모바일 S/W 프로그래밍 안드로이드개발환경설치 2012.09.05. 오병우 모바일공학과 JDK (Java Development Kit) SE (Standard Edition) 설치순서 Eclipse ADT (Android Development Tool) Plug-in Android SDK (Software Development Kit) SDK Components

More information

을풀면된다. 2. JDK 설치 JDK 는 Sun Developer Network 의 Java( 혹은 에서 Download > JavaSE 에서 JDK 6 Update xx 를선택하면설치파일을

을풀면된다. 2. JDK 설치 JDK 는 Sun Developer Network 의 Java(  혹은   에서 Download > JavaSE 에서 JDK 6 Update xx 를선택하면설치파일을 안드로이드설치및첫번째예제 안드로이드설치 안드로이드개발킷은안드로이드개발자사이트 (http://developer.android.com/) 에서다운로드받을수있으며현재 1.5 버전으로윈도우즈, 맥 OS X( 인텔 ), 리눅스플랫폼패키지가링크되어져있다. 안드로이드개발킷을설치하기위해서는다음과같은시스템환경이갖추어져있어야한다. 플랫폼 Windows Mac Linux 지원환경

More information

이것은리스트뷰의 setadapter 메소드에잘표현되어있습니다. setadapter 는리스트뷰에사용할데이터객체를넘겨주는메소드입니다. 일반적으로생각한다면 ArrayAdapter 객체를생성하여사용할데이터를저장할것이고데이터가저장된 ArrayAdapter 객체를 setadapt

이것은리스트뷰의 setadapter 메소드에잘표현되어있습니다. setadapter 는리스트뷰에사용할데이터객체를넘겨주는메소드입니다. 일반적으로생각한다면 ArrayAdapter 객체를생성하여사용할데이터를저장할것이고데이터가저장된 ArrayAdapter 객체를 setadapt 1. 리스트뷰의구조 리스트뷰는어떤데이터그룹에대한각각의정보들을항목별로출력시키고사용자에게원하는항목을검색하거나선택할수있도록해주는컨트롤객체입니다. 그래서다른컨트롤처럼정해진형태의정보를저장하는것이아니기때문에리스트뷰가데이터를직접관리하기는힘들었을것입니다. 그래서효과적인데이터관리를위해 "ArrayAdapter" 라는클래스가추가되었고리스트뷰는이클래스를이용해서사용자가지정한데이터에접근하도록구현되어있습니다.

More information

학습목표 메뉴를추가하는방법을이해하고실습할수있다. 프로그램의기본설정 (settings) 을정의하는방법을알고실습할수있다. 대화상자를여는방법을알고실습할수있다. 로그메시지로디버깅하는방법을이해한다. 디버거로디버깅하는방법을이해한다.

학습목표 메뉴를추가하는방법을이해하고실습할수있다. 프로그램의기본설정 (settings) 을정의하는방법을알고실습할수있다. 대화상자를여는방법을알고실습할수있다. 로그메시지로디버깅하는방법을이해한다. 디버거로디버깅하는방법을이해한다. 헬로, 안드로이드 4 주차 사용자인터페이스디자인하기 (2) 강대기동서대학교컴퓨터정보공학부 학습목표 메뉴를추가하는방법을이해하고실습할수있다. 프로그램의기본설정 (settings) 을정의하는방법을알고실습할수있다. 대화상자를여는방법을알고실습할수있다. 로그메시지로디버깅하는방법을이해한다. 디버거로디버깅하는방법을이해한다. 차례 메뉴추가하기 Settings 추가하기 새게임시작하기

More information

슬라이드 1

슬라이드 1 모바일소프트웨어프로젝트 지도 API 1 조 20070216 김성수 20070383 김혜준 20070965 이윤상 20071335 최진 1 매시업? 공개 API? 2 매시업 웹으로제공하고있는정보와서비스를융합하여새로운소프트웨어나서비스, 데이터베이스등을만드는것 < 최초의매시업 > 3 공개 API 누구나사용할수있도록공개된 API 지도, 검색등다양한서비스들에서제공 대표적인예

More information

슬라이드 1

슬라이드 1 Android Mobile Application Development Part 1 Agenda Part 1 About Android Build Develop Environment Create new Project Composition of Project Simulate Application Part 2 User Interface Activity Toast Preference

More information

1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과

1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과 1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과 학습내용 1. Java Development Kit(JDK) 2. Java API 3. 자바프로그래밍개발도구 (Eclipse) 4. 자바프로그래밍기초 2 자바를사용하려면무엇이필요한가? 자바프로그래밍개발도구 JDK (Java Development Kit) 다운로드위치 : http://www.oracle.com/technetwork/java/javas

More information

안드로이드2_14

안드로이드2_14 .,,,,,. 11...,,,.,.,.,. Chapter 14. force feedback.., getsystemservice. String service_name = Context.SENSOR_SERVICE; SensorManager sensormanager = (SensorManager)getSystemService(service_name);. Sensor.,,,.

More information

슬라이드 1

슬라이드 1 Android Mobile Application Development Part 2 Agenda Part 1 Build Develop Environment Create new Project Composition of Project Simulate Application Part 2 User Interface Activity Toast Preference Log

More information

// 화면을터치하였을때해야할작업구현 case MotionEvent.ACTION_MOVE: // 화면을드래그하였때 // 화면을드래그하였을때해야할작업구현 case MotionEvent.ACTION_UP: // 화면에서터치가사라질때 // 화면에서터치가사라질때해야할자업구현 c

// 화면을터치하였을때해야할작업구현 case MotionEvent.ACTION_MOVE: // 화면을드래그하였때 // 화면을드래그하였을때해야할작업구현 case MotionEvent.ACTION_UP: // 화면에서터치가사라질때 // 화면에서터치가사라질때해야할자업구현 c 6 차시이벤트처리 1 학습목표 터치이벤트처리를배운다. XML 의 onclick 속성을사용하여이벤트를처리한다. 2 확인해볼까? 3 이벤트처리하기 1) 학습하기 터치이벤트 public boolean ontouchevent(motionevent event) { swtich(event.getaction()) { case MotionEvent.ACTION_DOWN:

More information

Microsoft PowerPoint - 11주차_Android_GoogleMap.ppt [호환 모드]

Microsoft PowerPoint - 11주차_Android_GoogleMap.ppt [호환 모드] Google Map View 구현 학습목표 교육목표 Google Map View 구현 Google Map 지원 Emulator 생성 Google Map API Key 위도 / 경도구하기 위도 / 경도에따른 Google Map View 구현 Zoom Controller 구현 Google Map View (1) () Google g Map View 기능 Google

More information

위젯과레이아웃위젯은 View 클래스를상속해화면디스플레이와이벤트처리를할수있도록구현된스크린구성의최소단위를말한다. android.widget 패키지에는여러유형의위젯들이포함되어있다. TextView, ImageView, Button, ImageButton 등은가장간단한위젯들이

위젯과레이아웃위젯은 View 클래스를상속해화면디스플레이와이벤트처리를할수있도록구현된스크린구성의최소단위를말한다. android.widget 패키지에는여러유형의위젯들이포함되어있다. TextView, ImageView, Button, ImageButton 등은가장간단한위젯들이 구글안드로이드프로그래밍 GUI 설계, 위젯과레이아웃 QVGA급컬러 LCD 가대세가되어버린최근의휴대폰환경에서는 GUI 도모바일애플리케이션개발의매우중요한요소로자리잡았다. 이번달에는안드로이드플랫폼의 GUI 프레임워크를살펴보도록하자. 5 연재순서 1 회 2008. 1 애플리케이션구조분석 2 회 2008. 2 GUI 설계, 위젯과레이아웃 3 회 2008. 3 액티비티와인텐트,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Hello Android Jo, Heeseung Contents HelloAndroid program AVD 명칭과사용법안드로이드응용프로그램작성안드로이드프로젝트구성 2 처음만드는 [Hello Android] 프로그램 3 처음만드는 [Hello Android] 프로그램 이클립스메뉴 [File]-[New]-[Project] 를선택 [New Project] 창에서

More information

OpenCV와 함께하는 컴퓨터 비전 프로그래밍 캠프

OpenCV와 함께하는 컴퓨터 비전 프로그래밍 캠프 OpenCV 와함께하는컴퓨터비전프로그래밍캠프 Appx. 안드로이드 OpenCV 프로그래밍 Last Update: 2018/06/07 Visual C++ 영상처리프로그래밍 저자 황선규 / 공학박사 sunkyoo.hwang@gmail.com 모바일컴퓨터비전프로그래밍 목차 Android 개요 Android 개발환경구축 Android Studio 설치 OpenCV

More information

서현수

서현수 Introduction to TIZEN SDK UI Builder S-Core 서현수 2015.10.28 CONTENTS TIZEN APP 이란? TIZEN SDK UI Builder 소개 TIZEN APP 개발방법 UI Builder 기능 UI Builder 사용방법 실전, TIZEN APP 개발시작하기 마침 TIZEN APP? TIZEN APP 이란? Mobile,

More information

콘텐츠 PowerPoint 디자인

콘텐츠 PowerPoint 디자인 서비스 / 스레드 /DB 최 민 서비스 Service 안드로이드는서비스에게비활성액티비티보다높은우선순위부여 시스템이리소스를필요로할때서비스가종료될가능성은적음 서비스가종료되었더라도리소스가충분해지면즉시재시작 GUI 없이실행 Activity, Broadcast receiver와같이애플리케이션프로세스의메인쓰레드내에서실행 좋은반응성을가지려면시간이많이드는처리 ( 네트워크조회등

More information

50_1953.pdf

50_1953.pdf C h a p t e r 02 194 Part Mobile Apps 01 01 02 Chapter 02 195 03 04 196 Part 02 01 02 03 04 Chapter 02 197 05 06 07 08 198 Part 03 01 02 Chapter 02 199 03 04 05 06 200 Part 07 08 09 10 Chapter 02 201 04

More information

슬라이드 1

슬라이드 1 13 장. 커스텀뷰개발 API 에서제공하는뷰를그대로이용하면서약간변형시킨뷰 여러뷰를합쳐서한번에출력하기위한뷰 기존 API 에전혀존재하지않는뷰 public class MyView extends TextView { public class MyView extends ViewGroup { public class MyView extends View { 커스텀뷰를레이아웃

More information

Microsoft PowerPoint Android-구조.애플리케이션 기초(1.0h).pptx

Microsoft PowerPoint Android-구조.애플리케이션 기초(1.0h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 안드로이드정의및아키텍처 안드로이드커널접근 애플리케이션기초및컴포넌트 2 안드로이드는운영체제 (operating system), 미들웨어 (middleware), 핵심애플리케이션들 (key applications) 을포함하고있는모바일디바이스를위한소프트웨어스택 (software stack)

More information

2_안드로이드UI

2_안드로이드UI 03 Layouts 레이아웃 (Layout) u ViewGroup의파생클래스로서, 포함된 View를정렬하는기능 u 종류 LinearLayout 컨테이너에포함된뷰들을수평또는수직으로일렬배치하는레이아웃 RelativeLayout 뷰를서로간의위치관계나컨테이너와의위치관계를지정하여배치하는레이아웃 TableLayout 표형식으로차일드를배치하는레이아웃 FrameLayout

More information

제8장 자바 GUI 프로그래밍 II

제8장 자바 GUI 프로그래밍 II 제8장 MVC Model 8.1 MVC 모델 (1/7) MVC (Model, View, Controller) 모델 스윙은 MVC 모델에기초를두고있다. MVC란 Xerox의연구소에서 Smalltalk 언어를바탕으로사용자인터페이스를개발하기위한방법 MVC는 3개의구성요소로구성 Model : 응용프로그램의자료를표현하기위한모델 View : 자료를시각적으로 (GUI 방식으로

More information

슬라이드 1

슬라이드 1 핚국산업기술대학교 제 14 강 GUI (III) 이대현교수 학습안내 학습목표 CEGUI 라이브러리를이용하여, 게임메뉴 UI 를구현해본다. 학습내용 CEGUI 레이아웃의로딩및렌더링. OIS 와 CEGUI 의연결. CEGUI 위젯과이벤트의연동. UI 구현 : 하드코딩방식 C++ 코드를이용하여, 코드내에서직접위젯들을생성및설정 CEGUI::PushButton* resumebutton

More information

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V Mobile Service > IAP > Android SDK IAP SDK TOAST SDK. IAP SDK. Android Studio IDE 2.3.3 Android SDK Version 2.3.3 (API Level 10). Name Reference Version License okhttp http://square.github.io/okhttp/ 1.5.4

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Basic Widgets Jo, Heeseung Contents 뷰의개요 기본위젯다루기 기본위젯활용하기 2 뷰의개요 안드로이드화면에서실제로사용되는것은모두 View 클래스에서상속 이러한클래스를모두 ' 위젯 ' ( 또는뷰 ) 이라고도부름 위젯중에서다른위젯을담을수있는것들은주로 ViewGroup 클래스의하위에존재 이렇게다른위젯을담을수있는클래스를레이아웃이라고함 위젯

More information

(Microsoft PowerPoint - Ch06.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - Ch06.ppt [\310\243\310\257 \270\360\265\345]) Google Android 심화 학습 Dae-Ki Kang 개발 도구들(Development Tools) Android Emulator 에뮬레이터 Hierarchy Viewer 구조 뷰어 Draw 9-patch Android Development Tools Plugin for the Eclipse IDE 개발 툴 Dalvik Debug Monitor Service

More information

Microsoft PowerPoint - DoItAndroid_PART02_01_기본위젯과레이아웃_Rev.1.0 [호환 모드]

Microsoft PowerPoint - DoItAndroid_PART02_01_기본위젯과레이아웃_Rev.1.0 [호환 모드] Do It! 안드로이드앱프로그래밍 PART 0 Chapter 01 기본위젯과레이아웃 Sep. 011 이지스퍼블리싱 ( 주 ) 제공강의교안저자 : 정재곤 이번장에서는무엇을다룰까요? 이번장에서는무엇을다룰까요? 화면을먼저만들어보고싶어요. 레이아웃을이용해 뷰란무엇일까요? 뷰를화면에배치해볼까요? 기본위젯사용하기 뷰란무엇일까요? 버튼 검색어 안드로이드 텍스트 레이아웃을이용해뷰를화면에배치해볼까요?

More information

슬라이드 1

슬라이드 1 전자정부개발프레임워크 1 일차실습 LAB 개발환경 - 1 - 실습목차 LAB 1-1 프로젝트생성실습 LAB 1-2 Code Generation 실습 LAB 1-3 DBIO 실습 ( 별첨 ) LAB 1-4 공통컴포넌트생성및조립도구실습 LAB 1-5 템플릿프로젝트생성실습 - 2 - LAB 1-1 프로젝트생성실습 (1/2) Step 1-1-01. 구현도구에서 egovframe>start>new

More information

Microsoft PowerPoint - 04기본위젯(Ver 1.0)

Microsoft PowerPoint - 04기본위젯(Ver 1.0) 04. 기본위젯익히기 IT CookBook, 안드로이드프로그래밍 학습목표 뷰와뷰상속을이해한다. 기본위젯을다루는방법을익힌다. 안드로이드앱의기본적인프로그래밍을숙달한다. Page 3 차례 Page 4 1. 뷰의개요 뷰와뷰그룹 안드로이드화면에서실제로사용되는것은모두 View 클래스에서상속을받으며, 이러한클래스를모두 ' 위젯 '( 또는뷰 ) 이라고도부름. 위젯중에서다른위젯을담을수있는것들은주로

More information

슬라이드 1

슬라이드 1 IntelliJ IDEA 1. 도구개요 2. 설치및실행 3. 주요기능 1. 도구개요 도구명 IntelliJ IDEA (http://www.jetbrains.com/idea/) 라이선스 Apache 2 소개 Java 용통합개발도구 요구사항을정의하고전체개발과정에서요구사항을추적할수있도록지원. 특징 Java IDE 환경제공 모바일및엔터프라이저개발을위한프레임워크제공

More information

Microsoft PowerPoint App Fundamentals[Part1](1.0h).pptx

Microsoft PowerPoint App Fundamentals[Part1](1.0h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 애플리케이션기초 애플리케이션컴포넌트 액티비티와태스크 Part 1 프로세스와쓰레드 컴포넌트생명주기 Part 2 2 Library Java (classes) aapk.apk (android package) identifiers Resource & Configuration aapk: android

More information

Microsoft PowerPoint - 02처음으로만드는(Ver 1.0)

Microsoft PowerPoint - 02처음으로만드는(Ver 1.0) 02. 처음으로만드는안드로이드응용프로그램 IT CookBook, 안드로이드프로그래밍 학습목표 안드로이드응용프로그램의기본적인작성법을익힌다. AVD 의명칭을배운다. 안드로이드프로젝트의구성을파악한다. Page 2 차례 Page 3 1. 처음만드는 [Hello Android] 프로그램 Page 4 1. 처음만드는 [Hello Android] 프로그램 [ 실습 2-1]

More information

구글안드로이드프로그래밍액티비티, 인텐트수신자, 그리고서비스 안드로이드애플리케이션의구성요소에는액티비티, 인텐트수신자, 서비스, 컨텐트제공자가있다. 이번호에서는사용자인터페이스를위한액티비티와백그라운드서비스를위한인텐트수신자, 그리고서비스의라이프사이클과활용법에대해살펴보도록하자.

구글안드로이드프로그래밍액티비티, 인텐트수신자, 그리고서비스 안드로이드애플리케이션의구성요소에는액티비티, 인텐트수신자, 서비스, 컨텐트제공자가있다. 이번호에서는사용자인터페이스를위한액티비티와백그라운드서비스를위한인텐트수신자, 그리고서비스의라이프사이클과활용법에대해살펴보도록하자. 구글안드로이드프로그래밍액티비티, 인텐트수신자, 그리고서비스 안드로이드애플리케이션의구성요소에는액티비티, 인텐트수신자, 서비스, 컨텐트제공자가있다. 이번호에서는사용자인터페이스를위한액티비티와백그라운드서비스를위한인텐트수신자, 그리고서비스의라이프사이클과활용법에대해살펴보도록하자. 6 연재순서 1 회 2008. 1 애플리케이션구조분석 2 회 2008. 2 GUI 설계,

More information

TipssoftAppActivity.java // 기본소스파일 main.xml // 배치와구성에관련된리소스파일 string.xml // 프로그램에서사용할문자열에관련된리소스파일 컴파일을하고나면 r.java 라는소스파일이하나추가되는데이파일은리소스파일을소스파일에서이용할수있도

TipssoftAppActivity.java // 기본소스파일 main.xml // 배치와구성에관련된리소스파일 string.xml // 프로그램에서사용할문자열에관련된리소스파일 컴파일을하고나면 r.java 라는소스파일이하나추가되는데이파일은리소스파일을소스파일에서이용할수있도 1. " 소스파일 " 과 " 리소스파일 " 에대하여 소스파일은우리가흔히알고있듯이프로그래밍언어를사용해서자신이만들고자하는프로그램을구현한파일입니다. 예전에작성된프로그램들은소스파일만으로이루어진프로그램도많았습니다. 하지만, 프로그램환경이점점더복잡해지고사용자인터페이스가다양해지면서인터페이스구성을서술식으로나열해서소스파일에표현하는것은한계가왔고작업효율을떨어트리게되어해결책이필요하게되었습니다.

More information

Microsoft PowerPoint - Mobile SW Platform And Service Talk pptx

Microsoft PowerPoint - Mobile SW Platform And Service Talk pptx Mobile S/W Platform 및 Service 동향 서상범상무, Ph. D. System SW Lab. SW Platform Team SW Center Samsung Electronics 2011. 12.27 Contents 1. Smartphone Market 2. Mobile S/W Platform 3. Mobile Service 4. Conclusion

More information

슬라이드 1

슬라이드 1 개발홖경구축 시작하면서 2 목차 소프트웨어다운로드 JDK 설치및설정 안드로이드 SDK 설치및설정 이클립스설치및설정 안드로이드 SDK 둘러보기 소프트웨어다운로드 설치준비 4 필요한소프트웨어 JDK 5.0 이상 안드로이드 SDK 이클립스 다운로드할폴더생성 D:\android 폴더생성 D:\android\software 폴더생성 JDK 다운로드 5 JAVA 웹사이트접속

More information

<4D F736F F F696E74202D A434F20B9DFC7A5C0DAB7E1202D20C7AABDC3BCADB9F62DB0D4BDC3BABB2E >

<4D F736F F F696E74202D A434F20B9DFC7A5C0DAB7E1202D20C7AABDC3BCADB9F62DB0D4BDC3BABB2E > 2010 JCO Festival A 1 안드로이드기반의푸시서버기술 Android Based Push Server Technology 아첸자바커뮤니티 a java com 발표주제 안드로이드기반의푸시서버기술 Android Based Push Server Technology Jaom 2 Mobile Market Growth 모바일시장의성장 네트워크기술이모바일장비로확대

More information

Microsoft PowerPoint UI-Event.Notification(1.5h).pptx

Microsoft PowerPoint UI-Event.Notification(1.5h).pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 UI 이벤트 Event listener Touch mode Focus handling Notification Basic toast notification Customized toast notification Status bar notification 2 사용자가인터랙션하는특정 View

More information

SQL Developer Connect to TimesTen 유니원아이앤씨 DB 기술지원팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 작성자

SQL Developer Connect to TimesTen 유니원아이앤씨 DB 기술지원팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 작성자 SQL Developer Connect to TimesTen 유니원아이앤씨 DB 팀 2010 년 07 월 28 일 문서정보 프로젝트명 SQL Developer Connect to TimesTen 서브시스템명 버전 1.0 문서명 작성일 2010-07-28 작성자 김학준 최종수정일 2010-07-28 문서번호 20100728_01_khj 재개정이력 일자내용수정인버전

More information

Google Maps Android API v2

Google Maps Android API v2 Google Maps API 3 조 20080388 김현철 20080748 양태욱 20091493 김이현 Google Maps? 구글에서제공하는지도서비스 걷기, 차량두가지길찾기기능제공 최근, Open API 로현지대중교통과연동하여사용 Google Maps API? 개발자에게 Google Maps 를삽입할수있도록 Google 에서제공하는 Application

More information

HTML5* Web Development to the next level HTML5 ~= HTML + CSS + JS API

HTML5* Web Development to the next level HTML5 ~= HTML + CSS + JS API WAC 2.0 & Hybrid Web App 권정혁 ( @xguru ) 1 HTML5* Web Development to the next level HTML5 ~= HTML + CSS + JS API Mobile Web App needs Device APIs Camera Filesystem Acclerometer Web Browser Contacts Messaging

More information

Microsoft PowerPoint App Fundamentals[Part1].pptx

Microsoft PowerPoint App Fundamentals[Part1].pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 2 HangulKeyboard.apkapk 파일을다운로드 안드로이드 SDK 의 tools 경로아래에복사한후, 도스상에서다음과같이 adb 명령어수행 adb install HangulKeyboard.apk 이클립스에서에뮬레이터를구동 에뮬레이터메인화면에서다음과같이이동 메뉴버튼 설정 언어및키보드

More information

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다.

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다. Eclipse 개발환경에서 WindowBuilder 를이용한 Java 프로그램개발 이예는 Java 프로그램의기초를이해하고있는사람을대상으로 Embedded Microcomputer 를이용한제어시스템을 PC 에서 Serial 통신으로제어 (Graphical User Interface (GUI) 환경에서 ) 하는프로그램개발예를설명한다. WindowBuilder:

More information

THE TITLE

THE TITLE Android System & Launcher Team 8 목차 Android 1) Android Feature 2) Android Architecture 3) Android 개발방법 4) Android Booting Process Dalvik 1) Dalvik VM 2) Dalvik VM Instance Application 1) Application Package

More information

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc NTAS and FRAME BUILDER Install Guide NTAS and FRAME BUILDER Version 2.5 Copyright 2003 Ari System, Inc. All Rights reserved. NTAS and FRAME BUILDER are trademarks or registered trademarks of Ari System,

More information

PowerPoint Template

PowerPoint Template 01. 안드로이드개요와 개발환경구축 01 안드로이드의개요 02 안드로이드의개발환경 03 안드로이드의개발환경구축 1. 안드로이드개요 스마트폰개요 스마트폰 통화기능 + 컴퓨터 + 다양한기능내장 (MP3, 카메라, DMB, GPS 등 ) 스마트폰역사 1992년 IBM사의사이먼 ( 최초 ) 1996년노키아 9000 2002년마이크로소프트포켓PC 2007년아이폰 2008년안드로이드폰

More information

슬라이드 1

슬라이드 1 - 1 - 전자정부모바일표준프레임워크실습 LAB 개발환경 실습목차 LAB 1-1 모바일프로젝트생성실습 LAB 1-2 모바일사이트템플릿프로젝트생성실습 LAB 1-3 모바일공통컴포넌트생성및조립도구실습 - 2 - LAB 1-1 모바일프로젝트생성실습 (1/2) Step 1-1-01. 구현도구에서 egovframe>start>new Mobile Project 메뉴를선택한다.

More information

전자공학설계실험 A 보고서 화 6A ~ 9B 박종태교수님 제출기한 ( 화 ) Android I.S 작업환경 Eclipse_Juno ver. 전자공학부 이상엽전자공학부 오윤재전자공학부

전자공학설계실험 A 보고서 화 6A ~ 9B 박종태교수님 제출기한 ( 화 ) Android I.S 작업환경 Eclipse_Juno ver. 전자공학부 이상엽전자공학부 오윤재전자공학부 전자공학설계실험 A 보고서 화 6A ~ 9B 박종태교수님 제출기한 12.12.04 ( 화 ) Android 4.0.1 I.S 작업환경 Eclipse_Juno ver. 전자공학부 2008037262 이상엽전자공학부 2008037233 오윤재전자공학부 2008037298 이준철 AppName Oh! My Taxi 택시요금예상측정기 목차 개발동기 본 App의차별성

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Application Framework 어플리케이션프레임워크 발표자 : 김준섭 이문서는나눔글꼴로작성되었습니다. 다운받기 목차 Application Framework. 1. 통지관리자 (Notification Manager) 2. 리소스관리자 (resource manager) 3. 레이아웃인플레이터매니저 (Layout Inflater Manager) Notification

More information

슬라이드 1

슬라이드 1 사용자인터페이스 (II) 시작하면서 2 목차 리스트뷰 : 어댑터, 어댑터뷰, 대화창 메뉴 리스트뷰 - 어댑터 Adapter 4 배열, XML 파일, 데이터베이스에서다양한종류의값을읽어오는공통의인터페이스 선택위젯에게데이터를제공, 각데이터항목들을위젯내부에표시하는위젯클래스로의변홖수행 사용자인터페이스인뷰와데이터소스를연결 Data Source: Array, XML, Database

More information

Dialog Box 실행파일을 Web에 포함시키는 방법

Dialog Box 실행파일을 Web에 포함시키는 방법 DialogBox Web 1 Dialog Box Web 1 MFC ActiveX ControlWizard workspace 2 insert, ID 3 class 4 CDialogCtrl Class 5 classwizard OnCreate Create 6 ActiveX OCX 7 html 1 MFC ActiveX ControlWizard workspace New

More information

Microsoft Word - 안드로이드_개발_매뉴얼1.docx

Microsoft Word - 안드로이드_개발_매뉴얼1.docx 안드로이드개발매뉴얼 2009/11/18 모비젠 TI연구소 MA연구팀허광남 kenu@mobigen.com From: http://www.android.com/goodies/ 목차 들어가며... 1 안드로이드개요... 1 안드로이드 SDK... 5 이클립스설치... 8 Hello Android 프로젝트만들기... 10 안드로이드프로젝트실행... 12 맺으며...

More information

<4D F736F F F696E74202D205BC3D6C1BE5D3133C1D6C2F720B8AEBDBAC6AEBAE420B0ADC0C7C0DAB7E12D >

<4D F736F F F696E74202D205BC3D6C1BE5D3133C1D6C2F720B8AEBDBAC6AEBAE420B0ADC0C7C0DAB7E12D > 13주차 A d a p t e rv i e w 학습내용 1. ListView 2. Spinner 3. GridView ListView AdapterView AdapterView - AdapterView 는항목에해당하는여러개의차일드뷰를통합하여화면에표시할수있음 - 리니어, 렐러티브같이배치만담당하는레이아웃과는달리사용자와상호작용도처리할수있으며항목의선택이가능함 AdapterView

More information

Special Theme _ 모바일웹과 스마트폰 본 고에서는 모바일웹에서의 단말 API인 W3C DAP (Device API and Policy) 의 표준 개발 현황에 대해서 살펴보고 관 련하여 개발 중인 사례를 통하여 이해를 돕고자 한다. 2. 웹 애플리케이션과 네이

Special Theme _ 모바일웹과 스마트폰 본 고에서는 모바일웹에서의 단말 API인 W3C DAP (Device API and Policy) 의 표준 개발 현황에 대해서 살펴보고 관 련하여 개발 중인 사례를 통하여 이해를 돕고자 한다. 2. 웹 애플리케이션과 네이 모바일웹 플랫폼과 Device API 표준 이강찬 TTA 유비쿼터스 웹 응용 실무반(WG6052)의장, ETRI 선임연구원 1. 머리말 현재 소개되어 이용되는 모바일 플랫폼은 아이폰, 윈 도 모바일, 안드로이드, 심비안, 모조, 리모, 팜 WebOS, 바다 등이 있으며, 플랫폼별로 버전을 고려하면 그 수 를 열거하기 힘들 정도로 다양하게 이용되고 있다. 이

More information

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Crash Unity SDK... Log & Crash Search. - Unity3D v4.0 ios

More information

오버라이딩 (Overriding)

오버라이딩 (Overriding) WindowEvent WindowEvent 윈도우가열리거나 (opened) 닫힐때 (closed) 활성화되거나 (activated) 비활성화될때 (deactivated) 최소화되거나 (iconified) 복귀될때 (deiconified) 윈도우닫힘버튼을누를때 (closing) WindowEvent 수신자 abstract class WindowListener

More information

Microsoft PowerPoint - 안드로이드 개발 환경 구축(170411)

Microsoft PowerPoint - 안드로이드 개발 환경 구축(170411) Android 7.0 Nougat 개발환경구축 목차 기존방식 JAVA JDK 다운로드및설치 Android SDK 다운로드및설치 Eclipse 다운로드및설치 Eclipse와의연동 AVD 생성과 Android 프로젝트생성및실행 Android Studio 를이용한방식 JAVA JDK 다운로드및설치 Android Studio 설치및프로젝트생성 기존방식 (Android

More information

헬로, 안드로이드 13 주차 SQL 활용하기 (2) 강대기동서대학교컴퓨터정보공학부

헬로, 안드로이드 13 주차 SQL 활용하기 (2) 강대기동서대학교컴퓨터정보공학부 헬로, 안드로이드 13 주차 SQL 활용하기 (2) 강대기동서대학교컴퓨터정보공학부 학습목표 데이터바인딩을통해데이터소스에해당하는데이터베이스와뷰에해당하는액티비티를연결한데이터베이스응용프로그램을작성할수있다. 안드로이드내의다른어플리케이션의데이터에접근하기위해제공되는 ContentProvider 를사용할수있다. 자신의어플리케이션에서다른어플리케이션으로의데이터제공을위한 ContentProvider

More information

rmi_박준용_final.PDF

rmi_박준용_final.PDF (RMI) - JSTORM http://wwwjstormpekr (RMI)- Document title: Document file name: Revision number: Issued by: Document Information (RMI)- rmi finaldoc Issue Date: Status:

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 홈네트워킹 public interface RemoteControl { public void turnon(); // 가전제품을켠다. public void turnoff(); // 가전제품을끈다. 인터페이스를구현 public class Television

More information

변수이름 변수값 PATH ;C:\Program Files\Java\jdk1.8.0_45\bin CLASSPATH.;C:\Program Files\jdk1.8.0_45\lib\tools.jar JAVA_HOME C:\Program Files\Java\jdk1.8.0_45

변수이름 변수값 PATH ;C:\Program Files\Java\jdk1.8.0_45\bin CLASSPATH.;C:\Program Files\jdk1.8.0_45\lib\tools.jar JAVA_HOME C:\Program Files\Java\jdk1.8.0_45 안드로이드앱개발과정추가교재 - Android Studio 사용 [ 실습 01] 개발환경설치 ( 안드로이드스튜디오 & Eclipse IDE + Android SDK) I. 안드로이드스튜디오 1. JDK 다운로드및설치 (1) JDK 다운로드 1 JDK다운로드를위해웹브라우저에 http://www.oracle.com/technetwork/java/javase/downloads/index.html

More information

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Spring Boot/JDBC JdbcTemplate/CRUD 예제 Spring Boot/JDBC JdbcTemplate/CRUD 예제 오라클자바커뮤니티 (ojc.asia, ojcedu.com) Spring Boot, Gradle 과오픈소스인 MariaDB 를이용해서 EMP 테이블을만들고 JdbcTemplate, SimpleJdbcTemplate 을이용하여 CRUD 기능을구현해보자. 마리아 DB 설치는다음 URL 에서확인하자.

More information

슬라이드 1

슬라이드 1 3 장안드로이드프로그램의 첫걸음 시작하면서 2 목차 프로젝트의생성하기 프로젝트파읷및소스코드이해 코드로문자열표시하기 문자열출력프로그램응용 프로젝트에새로운파읷 / 속성추가 프로젝트생성하기 프로젝트생성하기 4 < 실습 5-1>: Android 프로젝트의생성과에뮬레이터구동 (1)[ 그림 3-1](a) 처럼안드로이드프로젝트생성아이콘클릭 [ 그림 3-1](b) 처럼이클립스에서메뉴선택

More information

Contents v 학습목표 뷰와레이아웃에대해이해하고, 레이아웃을활용, 관리하는여러가지기법들에대하여알아본다. v 내용 뷰 (View) 리니어레이아웃 (Linear Layout)

Contents v 학습목표 뷰와레이아웃에대해이해하고, 레이아웃을활용, 관리하는여러가지기법들에대하여알아본다. v 내용 뷰 (View) 리니어레이아웃 (Linear Layout) 레이아웃 (Layout) 안드로이드프로그래밍정복 (Android Programming Complete Guide) Contents v 학습목표 뷰와레이아웃에대해이해하고, 레이아웃을활용, 관리하는여러가지기법들에대하여알아본다. v 내용 뷰 (View) 리니어레이아웃 (Linear Layout) v 뷰의계층 안드로이드응용프로그램의화면을구성하는주요단위인액티비티는화면에직접적으로보이지않으며,

More information

학습목표 인텐트로다른액티비티나프로그램을실행시킬수있다. 웹뷰를통해웹화면을액티비티화면의일부로구성할수있다. 자바스크립트를통해안드로이드프로그램을호출하는방법을안다. 안드로이드응용프로그램에서웹서비스를이용하는방법을안다.

학습목표 인텐트로다른액티비티나프로그램을실행시킬수있다. 웹뷰를통해웹화면을액티비티화면의일부로구성할수있다. 자바스크립트를통해안드로이드프로그램을호출하는방법을안다. 안드로이드응용프로그램에서웹서비스를이용하는방법을안다. 헬로, 안드로이드 10 주차 연결된세상 강대기동서대학교컴퓨터정보공학부 학습목표 인텐트로다른액티비티나프로그램을실행시킬수있다. 웹뷰를통해웹화면을액티비티화면의일부로구성할수있다. 자바스크립트를통해안드로이드프로그램을호출하는방법을안다. 안드로이드응용프로그램에서웹서비스를이용하는방법을안다. 차례 인텐트로브라우징하기 뷰안의웹 자바스크립트에서자바로, 자바에서자바스크립트로 웹서비스이용하기

More information

<4D F736F F D20284B B8F0B9D9C0CF20BED6C7C3B8AEC4C9C0CCBCC720C4DCC5D9C3F720C1A2B1D9BCBA2020C1F6C4A720322E302E646F6378>

<4D F736F F D20284B B8F0B9D9C0CF20BED6C7C3B8AEC4C9C0CCBCC720C4DCC5D9C3F720C1A2B1D9BCBA2020C1F6C4A720322E302E646F6378> KSKSKSKS KSKSKSK KSKSKS KSKSK KSKS KSK KS X 3253 KS 2.0 KS X 3253 2016 2016 10 20 3 ... ii... iii 1... 1 2... 1 3... 1 3.1... 1 3.2... 3 4... 3 5... 4 6... 5 7... 7 8... 7 9... 8 A ( )... 9 A.1... 9 A.2...

More information

¾Èµå·ÎÀÌµå ³¹Àå-Åë.PDF

¾Èµå·ÎÀÌµå ³¹Àå-Åë.PDF 시작하기 시작하기 :: 학습목표 :: 이클립스에서새로운 Project를만들수있다 View를디자인하고프로그램에연결할수있다 버튼의 Listener를작성할수있다 작성한 Listener를여러개의버튼이공유하게할수있다 일정한범위의난수를만들수있다 난수의발생빈도를조절할수있다 프로그램에서 ImageView의비트맵을바꿀수있다 1.1 시작하기에앞서 프로그램의기본흐름은입력, 처리,

More information

PowerPoint Template

PowerPoint Template 3. 안드로이드개발환경설치 Android Studio 설정 [1/13] [Windows 시작 ]-[ 모든앱 ]-[Android Studio] 의 Android Studio 를실행 Page 34 3. 안드로이드개발환경설치 Android Studio 설정 [2/13] 첫설치이므로다음과같은선택화면이나오면아래쪽 I do not have a previous~ 가 선택된상태에서

More information

REMON Android SDK GUIDE (SDK Version 1.4.1) 1 / 25

REMON Android SDK GUIDE (SDK Version 1.4.1) 1 / 25 REMON Android SDK GUIDE (SDK Version 1.4.1) 1 / 25 문서개정내역 변경일버전변경내용비고 2014.06.30 1.0.0 최초작성 2014.09.30 1.1.0 개인정보항목변경, 개인정보이용약관기능추가 2014.12.01 1.2.0 Proguard 추가 2014.12.16 1.2.0 Android Studio 기준샘플및가이드추가

More information

쉽게 풀어쓴 C 프로그래밊

쉽게 풀어쓴 C 프로그래밊 Power Java 제 27 장데이터베이스 프로그래밍 이번장에서학습할내용 자바와데이터베이스 데이터베이스의기초 SQL JDBC 를이용한프로그래밍 변경가능한결과집합 자바를통하여데이터베이스를사용하는방법을학습합니다. 자바와데이터베이스 JDBC(Java Database Connectivity) 는자바 API 의하나로서데이터베이스에연결하여서데이터베이스안의데이터에대하여검색하고데이터를변경할수있게한다.

More information

헬로, 안드로이드 11 주차 위치파악하기와감지하기 강대기동서대학교컴퓨터정보공학부

헬로, 안드로이드 11 주차 위치파악하기와감지하기 강대기동서대학교컴퓨터정보공학부 헬로, 안드로이드 11 주차 위치파악하기와감지하기 강대기동서대학교컴퓨터정보공학부 학습목표 GPS 장치를통해위치를인식하는방법에대해서알아본다. 가속도계에대해서알아본다. 지도를나타내는맵뷰에대해알아본다. 웹뷰와맵뷰를결합함으로써, 여러서비스들을결합하는매시업 (mashup) 에대해알아본다. 차례 위치, 위치, 위치 센서를최대로설정하기 조감도 웹뷰와맵뷰 요약 퀴즈 연습문제

More information

Microsoft PowerPoint UI-Layout.Menu.pptx

Microsoft PowerPoint UI-Layout.Menu.pptx To be an Android Expert 문양세강원대학교 IT 대학컴퓨터학부 User Interface 개요 Declaring Layout Creating Menus 2 View: user interface 의기본단위 사각형 (rectangle) 영역을차지하며, 그리기및이벤트처리의기본단위이다. Widget 을생성하기위한기본클래스이다. 예 : 버튼, 텍스트창,

More information

Facebook API

Facebook API Facebook API 2조 20071069 임덕규 20070452 류호건 20071299 최석주 20100167 김민영 목차 Facebook API 설명 Android App 생성 Facebook developers App 등록 Android App Facebook SDK 추가 예제 Error 사항정리 Facebook API Social Plugin Facebook

More information

JAVA PROGRAMMING 실습 08.다형성

JAVA PROGRAMMING 실습 08.다형성 2015 학년도 2 학기 1. 추상메소드 선언은되어있으나코드구현되어있지않은메소드 abstract 키워드사용 메소드타입, 이름, 매개변수리스트만선언 public abstract String getname(); public abstract void setname(string s); 2. 추상클래스 abstract 키워드로선언한클래스 종류 추상메소드를포함하는클래스

More information

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일 Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 Introduce Me!!! Job Jeju National University Student Ubuntu Korean Jeju Community Owner E-Mail: ned3y2k@hanmail.net Blog: http://ned3y2k.wo.tc Facebook: http://www.facebook.com/gyeongdae

More information

Chapter 1

Chapter 1 3 Oracle 설치 Objectives Download Oracle 11g Release 2 Install Oracle 11g Release 2 Download Oracle SQL Developer 4.0.3 Install Oracle SQL Developer 4.0.3 Create a database connection 2 Download Oracle 11g

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

안드로이드애플리케이션과통합하는데는자바가편하므로대표적인두가지라이브러리를비교해보자. 자바 ID3 태그라이브러리 jaudiotagger ID3v1, ID3v1.1, Lyrics3v1, Mp3, Mp4 (Mp4 오디오, M4a 지원범위 Lyrics3v2, ID3v2.2, ID

안드로이드애플리케이션과통합하는데는자바가편하므로대표적인두가지라이브러리를비교해보자. 자바 ID3 태그라이브러리 jaudiotagger ID3v1, ID3v1.1, Lyrics3v1, Mp3, Mp4 (Mp4 오디오, M4a 지원범위 Lyrics3v2, ID3v2.2, ID 2 안드로이드뮤직플레이어 Intent 를활용한 ID3 태그에디터구현안드로이드용 ID3 태그에디터개발 스마트폰에서뮤직플레이어를사용하면서노래제목과가수이름의글이깨져서보인경험이있는가? 필자는 MP3 의메타정보인 ID3 태그를편집할수있는에디터를만들어사용자의불편을개선하는애플리케이션을만들어배포하고있다. 이번호에서는 ID3 태그에디터를만들어보면서안드로이드에서음악정보를수정할수있는방법을알아보자.

More information

보안공학연구회

보안공학연구회 보안공학연구논문지 (Journal of Security Engineering), 제 9권 제 4호 2012년 8월 모바일 운영체제 동향 분석 배유미 1), 정성재 2), 소우영 3) Trend analysis of Mobile Operating Systems Yu-Mi Bae 1), Sung-Jae Jung 2), Wooyoung Soh 3) 요 약 최근 모바일

More information

레이아웃 (Layout)

레이아웃 (Layout) 레이아웃 (3 장 ) 김성영교수 금오공과대학교 컴퓨터공학부 Contents 학습목표 뷰와레이아웃에대해이해하고, 레이아웃을활용, 관리하는여러가 지기법들에대하여알아본다. 내용 뷰 (View) 리니어레이아웃 (Linear Layout) 다른레이아웃 레이아웃관리 2 액티비티 vs. 뷰 액티비티 (Activity) 안드로이드응용프로그램의화면을구성하는주요단위 여러개의액티비티가모여하나의응용프로그램을구성

More information

AGENDA 01 02 03 모바일 산업의 환경변화 모바일 클라우드 서비스의 등장 모바일 클라우드 서비스 융합사례

AGENDA 01 02 03 모바일 산업의 환경변화 모바일 클라우드 서비스의 등장 모바일 클라우드 서비스 융합사례 모바일 클라우드 서비스 융합사례와 시장 전망 및 신 사업전략 2011. 10 AGENDA 01 02 03 모바일 산업의 환경변화 모바일 클라우드 서비스의 등장 모바일 클라우드 서비스 융합사례 AGENDA 01. 모바일 산업의 환경 변화 가치 사슬의 분화/결합 모바일 업계에서도 PC 산업과 유사한 모듈화/분업화 진행 PC 산업 IBM à WinTel 시대 à

More information