13ÀåÃß°¡ºÐ

Similar documents
어댑터뷰

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

( )부록

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

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

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

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

03장

2 Application Name: Day10_yhg <LinearLayout android:layout_weight="3" > /> an

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

리니어레이아웃 - 2 -

슬라이드 1

SECTION 01 _ 액션바 (ActionBar) 405 액션바만들기 참고프로젝트 ActionBarDemoA1 간단히액션바를만들고이액션바가 WVGA(800*480) 과 WXGA(1280*800) 에서어떻게보이는지확인해보도록하겠다. 액션바를만든다는표현을했지만액션바는타이

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

PowerPoint 프레젠테이션

안드로이드2_14

슬라이드 1

01장

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

슬라이드 1

Daum 카페

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

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

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

PowerPoint 프레젠테이션

RDS_MAN_NO 도로구간일련번호 NUMBER(12) BSI_INT_SN 기초구간일련번호 NUMBER(10) EQB_MAN_SN 건물군일련번호 NUMBER(10) BULD_SE_CD 건물구분코드 VARCHAR2(1) BULD_MNNM 건물본번 NUMBER(5) BUL

rmi_박준용_final.PDF

12-file.key

신림프로그래머_클린코드.key

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

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

슬라이드 1

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

02 C h a p t e r Java

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

OOP 소개

JMF3_심빈구.PDF

슬라이드 1

비긴쿡-자바 00앞부속

09-interface.key

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - 04-UDP Programming.ppt

레이아웃 (Layout)

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

Modern Javascript

<4D F736F F F696E74202D205BC3D6C1BE5D3133C1D6C2F720B8AEBDBAC6AEBAE420B0ADC0C7C0DAB7E12D >

PowerPoint 프레젠테이션

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

K&R2 Reference Manual 번역본

5장.key

03장.스택.key

자바GUI실전프로그래밍2_장대원.PDF

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

콘텐츠 PowerPoint 디자인

PowerPoint Presentation

초보자를 위한 C# 21일 완성

목차 1. Samsung In-App Purchase 소개 다운로드 IAP 3.0 Helper & Sample IAP 3 제약사항 IAP 3 개발모드 지원상품타입 IAP 3

歯JavaExceptionHandling.PDF

PowerPoint 프레젠테이션

ch09

2_안드로이드UI

2007백서-001-특집

¾Ë·¹¸£±âÁöħ¼�1-ÃÖÁ¾

01....b

00목차

(291)본문7

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

10장.key

학습목표 게임이나프로그램에옵션을추가하는방법을알아본다. 이전의프로그램을계속하기위해상태를저장하는방법을알아본다. 게임에서현재의실행위치를저장하는방법에대해알아본다. 내부의파일시스템을읽고쓰는방법에대해알아본다. SD 카드에접근하는방법에대해알아본다. 여러 UI 위젯들에대해알아본다.

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

50_1953.pdf

11장.key

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

Android Master Key Vulnerability

12 주차 인텐트

PowerPoint Presentation

untitled

3ÆÄÆ®-11

슬라이드 1

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

mytalk

Spring Data JPA Many To Many 양방향 관계 예제

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

12Àå PDF

자바로

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Cluster management software

JMF2_심빈구.PDF

5.스택(강의자료).key

Java

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

Microsoft PowerPoint - 14주차 강의자료

04장

제11장 프로세스와 쓰레드

adlibr-android_4.x

오핀 (OFIN) SDK Guide Fintech Mobile SDK Guide - Android V 1.0 OPPFLIB 1

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

쉽게 풀어쓴 C 프로그래밍

untitled

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

Transcription:

13 CHAPTER

13 CHAPTER 2

3

4

5

6

7

06 android:background="#ffffffff"> 07 <TextView 08 android:layout_width="fill_parent" 09 android:layout_height="fill_parent" 10 android:text="fragment #1" 11 android:textcolor="#ff000000" 12 android:gravity="center" /> 09 public class FragmentOne extends Fragment { 10 @Override 11 public View oncreateview(layoutinflater inflater, 12 ViewGroup container, Bundle savedinstancestate) { 13 return inflater.inflate(r.layout.fragment1, container, false); 14 } 15 } 8

05 <fragment 06 class="com.corea.fragment1.fragmentone" 07 android:id="@+id/fragment1" 08 android:layout_width="fill_parent" 09 android:layout_height="fill_parent" /> 9

10

13 public class Fragment2 extends Activity { ~~~ ~~~ 20 FragmentManager fm = getfragmentmanager(); 21 FragmentTransaction ft = fm.begintransaction(); 22 23 FragmentOne f1 = new FragmentOne(); 24 FragmentTwo f2 = new FragmentTwo(); 25 26 if(getwindowmanager().getdefaultdisplay() 27.getRotation()==Surface.ROTATION_0){ 28 ft.replace(android.r.id.content, f1); 29 } else { 11

30 ft.replace(android.r.id.content, f2); 31 } 32 33 ft.commit(); 34 } 35 36 public static class FragmentOne extends Fragment { 37 @Override 38 public View oncreateview(layoutinflater inflater, 39 ViewGroup container, Bundle savedinstancestate) { 40 return inflater.inflate(r.layout.fragment1, container, false); 41 } 42 } 43 44 public static class FragmentTwo extends Fragment { 45 @Override 46 public View oncreateview(layoutinflater inflater, 47 ViewGroup container, Bundle savedinstancestate) { 48 return inflater.inflate(r.layout.fragment1, container, false); 49 } 50 } 51 } 12

13

05 android:orientation="horizontal" > 06 <fragment 07 android:id="@id/android:list" 08 android:layout_width="0dip" 09 android:layout_weight="1" 10 android:layout_height="match_parent" 11 class="com.corea.fragment3.listfrag" /> 12 <fragment 13 android:id="@+id/detail" 14 android:layout_width="0dip" 15 android:layout_weight="5" 16 android:layout_height="match_parent" 17 class="com.corea.fragment3.detailfrag" /> 14

05 android:background="#ffffffff" 06 android:orientation="vertical" > 07 <TextView 08 android:id="@+id/tv" 09 android:layout_width="wrap_content" 10 android:layout_height="match_parent" 11 android:layout_gravity="center_horizontal center_vertical" 12 android:layout_margintop="20dip" 13 android:text="details" 14 android:textcolor="#00000000" 15 android:textappearance="?android:attr/textappearancelarge" /> 15

10 public class DetailFrag extends Fragment { 11 @Override 12 public View oncreateview(layoutinflater inflater, 13 ViewGroup container, Bundle savedinstancestate) { 14 return inflater.inflate(r.layout.detail, container, false); 15 } 16 17 public void settext(string item) { 18 TextView v = (TextView) getview().findviewbyid(r.id.tv); 19 v.settext(item); 20 } 21 } 16

3 public interface OnListItemSelectedListener { 4 public void onlistitemselected(int position); 5 } 10 public class ListFrag extends ListFragment { 11 OnListItemSelectedListener listener; 12 @Override 13 public void onattach(activity activity) { 14 super.onattach(activity); 15 try { 16 listener = (OnListItemSelectedListener)activity; 17 } catch (ClassCastException e) { 18 throw new ClassCastException(activity.toString() 19 + " must implement OnListItemSelectedListener interface"); 20 } 21 } 22 23 @Override 24 public void onactivitycreated(bundle savedinstancestate) { 25 super.onactivitycreated(savedinstancestate); 26 setlistadapter(new ArrayAdapter<String>(getActivity(), 27 android.r.layout.simple_list_item_1, 28 new String[] {"1", "2", "3", "4", "5"})); 29 } 30 17

31 @Override 32 public void onlistitemclick(listview l, View v, 33 int position, long id) { 34 listener.onlistitemselected(position); 35 } 36 } 06 public class Fragment3 extends Activity 07 implements OnListItemSelectedListener { 08 String[] numbers = 09 new String[] { "One", "Two", "Three", "Four", "Five"}; ~~~ ~~~ 18

16 public void onlistitemselected(int position) { 17 DetailFrag df = (DetailFrag) getfragmentmanager() 18.findFragmentById(R.id.detail); 19 if (df!= null && df.isinlayout()) { 20 df.settext(numbers[position]); 21 } 22 } 23 } 19

06 <fragment 07 android:id="@id/android:list" 08 android:layout_width="0dip" 09 android:layout_weight="1" 10 android:layout_height="match_parent" 11 class="com.corea.fragment4.listfrag"/> 12 <FrameLayout 13 android:id="@+id/detail" 20

14 android:layout_width="0dip" 15 android:layout_height="fill_parent" 16 android:layout_weight="5" 17 android:background="?android:attr/detailselementbackground" /> 10 public class DetailFrag extends Fragment { 11 @Override 12 public View oncreateview(layoutinflater inflater, 13 ViewGroup container, Bundle savedinstancestate) { 14 View v = inflater.inflate(r.layout.detail, container, false); 15 TextView tv = (TextView) v.findviewbyid(r.id.tv); 16 17 String[] numbers = getarguments().getstringarray("numbers"); 18 tv.settext(numbers[getarguments().getint("position", 0)]); 19 return v; 20 } 21 } 21

07 public class Fragment4 extends Activity 08 implements OnListItemSelectedListener { 09 String[] numbers = new String[] { "One", "Two", "Three", "Four", "Five"}; ~~~ ~~~ 16 public void onlistitemselected(int position) { 17 DetailFrag df = (DetailFrag) getfragmentmanager() 18.findFragmentById(R.id.detail); 19 if (df == null df.getarguments().getint("position", 0)!= position) { 20 df = new DetailFrag(); 21 Bundle b = new Bundle(); 22 b.putint("position", position); 23 b.putstringarray("numbers", numbers); 24 df.setarguments(b); 25 FragmentTransaction ft = getfragmentmanager().begintransaction(); 26 ft.replace(r.id.detail, df).addtobackstack(null).commit(); 27 } 22

28 } 29 } 23

05 <fragment 06 android:id="@id/android:list" 07 android:layout_width="match_parent" 08 android:layout_height="match_parent" 09 class="com.corea.fragment5.listfrag" /> 24

06 public class DetailActivity extends Activity { 07 @Override 08 protected void oncreate(bundle savedinstancestate) { 09 super.oncreate(savedinstancestate); 10 DetailFrag df = new DetailFrag(); 11 df.setarguments(getintent().getextras()); 12 getfragmentmanager().begintransaction() 13.add(android.R.id.content, df).commit(); 14 } 15 } 17 public void onlistitemselected(int position) { 18 Intent i = new Intent(this, DetailActivity.class); 19 Bundle b = new Bundle(); 20 b.putint("position", position); 21 b.putstringarray("numbers", numbers); 22 i.putextras(b); 23 startactivity(i); 24 } 25

26

27

getactionbar().setdisplayoptions( ); 28

<activity android:theme="@android:style/theme.holo.noactionbar"> getactionbar().hide(); getactionbar().show(); getactionbar().settitle(" ); 29

02 <menu xmlns:android="http://schemas.android.com/apk/res/android"> 03 <item 04 android:id="@+id/add" 05 android:title=" " 06 android:icon="@android:drawable/ic_menu_add" 07 android:showasaction="ifroom" /> 30

08 <item 09 android:id="@+id/refresh" 10 android:title=" " 11 android:showasaction="always withtext" /> 12 <item 13 android:id="@+id/search" 14 android:title=" " 15 android:icon="@android:drawable/ic_menu_search" 16 android:showasaction="always" /> 17 <item 18 android:id="@+id/share" 19 android:title=" " 20 android:icon="@android:drawable/ic_menu_share" 21 android:showasaction="never" /> 22 <item 23 android:id="@+id/etc" 24 android:title=" "/> 25 </menu> 31

06 <Button 07 android:id="@+id/showtitle" 08 android:layout_width="fill_parent" 09 android:layout_height="wrap_content" 10 android:text=" " 11 android:onclick="onbutton"/> 12 <Button 13 android:id="@+id/notitle" 14 android:layout_width="fill_parent" 15 android:layout_height="wrap_content" 16 android:text=" " 17 android:onclick="onbutton"/> 11 public class ActionBar1 extends Activity { 12 /** Called when the activity is first created. */ 13 @Override 14 public void oncreate(bundle savedinstancestate) { 15 super.oncreate(savedinstancestate); 16 setcontentview(r.layout.main); 17 getactionbar().sethomebuttonenabled(true); 18 } 19 20 @Override 32

21 public boolean oncreateoptionsmenu(menu menu) { 22 getmenuinflater().inflate(r.menu.menu, menu); 23 return true; 24 } 25 26 @Override 27 public boolean onoptionsitemselected(menuitem item) { 28 String text = null; 29 30 switch(item.getitemid()){ 31 case android.r.id.home: 32 text = "Home"; break; 33 case R.id.add: 34 text = "ifroom"; break; 35 case R.id.refresh: 36 text = "always withtext"; break; 37 case R.id.search: 38 text = "always"; break; 39 case R.id.share: 40 text = "never"; break; 41 case R.id.etc: 42 text = "default"; break; 43 default: 44 return false; 45 } 46 Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); 47 48 return true; 49 } 50 51 public void onbutton(view v) { 52 switch(v.getid()){ 53 case R.id.showtitle: 54 getactionbar().setdisplayoptions( 55 ActionBar.DISPLAY_SHOW_HOME 56 ActionBar.DISPLAY_SHOW_TITLE); 57 break; 33

58 case R.id.notitle: 59 getactionbar().setdisplayoptions( 60 ActionBar.DISPLAY_SHOW_HOME); 61 } 62 } 63 } 34

35

06 <Button 07 android:layout_width="fill_parent" 08 android:layout_height="wrap_content" 09 android:id="@+id/white" 10 android:text=" " 11 android:onclick="onbutton" /> 12 <Button 13 android:layout_width="fill_parent" 14 android:layout_height="wrap_content" 15 android:id="@+id/black" 16 android:text=" " 17 android:onclick="onbutton" /> 36

13 public void oncreate(bundle savedinstancestate) { ~~~ ~~~ 17 View v = getlayoutinflater().inflate(r.layout.button, null); 18 19 ActionBar ab = getactionbar(); 20 ab.setcustomview(v); 21 ab.setdisplayoptions(actionbar.display_show_home 22 ActionBar.DISPLAY_SHOW_TITLE 23 ActionBar.DISPLAY_SHOW_CUSTOM); 24 } 25 26 public void onbutton(view v) { 27 LinearLayout ll = (LinearLayout)findViewById(R.id.body); 28 switch(v.getid()) { 29 case R.id.white: 30 ll.setbackgroundcolor(color.white); 31 break; 32 case R.id.black: 33 ll.setbackgroundcolor(color.black); 34 } 35 } 36 } 37

38

2 <menu xmlns:android="http://schemas.android.com/apk/res/android"> 3 <item android:id="@+id/action_search" 4 android:title="search" 5 android:icon="@android:drawable/ic_menu_search" 6 android:showasaction="always" 7 android:actionviewclass="android.widget.searchview" /> 8 </menu> 15 public class ActionBar3 extends Activity implements OnQueryTextListener { 16 private SearchView sv; ~~~ ~~~ 25 public boolean oncreateoptionsmenu(menu menu) { 26 super.oncreateoptionsmenu(menu); 27 getmenuinflater().inflate(r.layout.searchview, menu); 28 MenuItem mi = menu.finditem(r.id.action_search); 29 sv = (SearchView) mi.getactionview(); 30 39

31 mi.setshowasactionflags(menuitem.show_as_action_if_room 32 MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); 33 SearchManager sm 34 = (SearchManager)getSystemService(Context.SEARCH_SERVICE); 35 if (sm!= null) { 36 List<SearchableInfo> searchables 37 = sm.getsearchablesinglobalsearch(); 38 SearchableInfo info 39 = sm.getsearchableinfo(getcomponentname()); 40 for (SearchableInfo inf : searchables) { 41 if (inf.getsuggestauthority()!= null 42 && inf.getsuggestauthority().startswith("applications")) { 43 info = inf; 44 } 45 } 46 sv.setsearchableinfo(info); 47 } 48 sv.setonquerytextlistener(this); 49 sv.setqueryhint(" "); 50 return true; 51 } 52 53 public boolean onquerytextchange(string newtext) { 54 return false; 55 } 56 57 public boolean onquerytextsubmit(string query) { 58 return false; 59 } 60 } 40

41

06 android:background="#ffffffff"> 07 <TextView 08 android:layout_width="fill_parent" 09 android:layout_height="fill_parent" 10 android:text="text Fragment" 11 android:textcolor="#ff000000" 12 android:gravity="center" /> 06 android:background="#ffffffff"> 07 <ImageView 08 android:layout_width="fill_parent" 09 android:layout_height="fill_parent" 10 android:src="@drawable/ic_launcher" 11 android:gravity="center" /> 42

5 <LinearLayout 6 android:id="@+id/fragment" 7 android:layout_width="match_parent" 8 android:layout_height="match_parent" /> 12 public class ActionBar4 extends Activity implements TabListener { 13 Fragment frag1, frag2; 14 /** Called when the activity is first created. */ 15 @Override 16 public void oncreate(bundle savedinstancestate) { 17 super.oncreate(savedinstancestate); 18 setcontentview(r.layout.main); 19 20 ActionBar ab = getactionbar(); 21 ab.setnavigationmode(actionbar.navigation_mode_tabs); 22 frag1 = new FragmentOne(); 23 frag2 = new FragmentTwo(); 24 ab.addtab(ab.newtab().settext("text Fragment") 25.setTabListener(this)); 26 ab.addtab(ab.newtab().settext("image Fragment") 27.setTabListener(this)); 28 } 29 30 public void ontabreselected(tab tab, FragmentTransaction ft) { 43

31 Toast.makeText(this, "Reselected!", Toast.LENGTH_LONG).show(); 32 } 33 34 public void ontabselected(tab tab, FragmentTransaction ft) { 35 ft.replace(r.id.fragment, tab.getposition() == 0? frag1 : frag2); 36 } 37 38 public void ontabunselected(tab tab, FragmentTransaction ft) { 39 ft.remove(tab.getposition() == 0? frag1 : frag2); 40 } 41 } 44

07 <string-array name="list"> 08 <item>text Fragment</item> 09 <item>image Fragment</item> 10 </string-array> 45

11 public class ActionBar5 extends Activity implements OnNavigationListener { 12 /** Called when the activity is first created. */ 13 @Override 14 public void oncreate(bundle savedinstancestate) { 15 super.oncreate(savedinstancestate); 16 setcontentview(r.layout.main); 17 18 ActionBar ab = getactionbar(); 19 ab.setnavigationmode(actionbar.navigation_mode_list); 20 SpinnerAdapter sa = ArrayAdapter.createFromResource(this, 21 R.array.list, android.r.layout.simple_spinner_dropdown_item); 22 23 ab.setlistnavigationcallbacks(sa, this); 24 } 25 26 public boolean onnavigationitemselected(int itemposition, long itemid) { 27 Fragment frag1 = new FragmentOne(); 28 Fragment frag2 = new FragmentTwo(); 29 30 getfragmentmanager() 31.beginTransaction() 32.replace(R.id.fragment, itemposition == 0? frag1 : frag2) 33.commit(); 34 return true; 35 } 36 } 46

47

1 2 3 4 5 6 7 48