아주대학교 LifecareScienceLAB Android Seminar 3 rd class Android Software Development 2011/05/04 – p.m. 06:00 – 팔달관 409 호 아주대학교.

Slides:



Advertisements
Similar presentations
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Advertisements

Who Am I And Why Am I Here I’m professor Stephen Fickas in CIS – you can call me Steve. I have a research group that works with mobile devices (since 1995!)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
@2011 Mihail L. Sichitiu1 Android Introduction Communication between Activities.
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
ANDROID – INTERFACE AND LAYOUT L. Grewe. Interfaces: Two Alternatives Code or XML  You have two ways you can create the interface(s) of your Application.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Dialog Boxes AlertDialog - Toast
Android - Broadcast Receivers
Import import android.graphics.Bitmap; import android.widget.ImageView;
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
목차 한국기술교육대학교 강사: 김 영 준 ㈜헬로앱스 1일차 아두이노 제어 실습
Android and s Ken Nguyen Clayton state University 2012.
CHAP 14. 프로세스와 스레드. © 2012 생능출판사 All rights reserved 다중 스레딩 하나의 애플리케이션이 동시에 여러 가지 작업을 하 는 것 이들 작업은 스레드 (thread) 라고 불린다.
Activity ANDROID CLUB Сегодня  Основные компоненты Android  Activity  Layout для Activity  Создание Activity  Launcher Activity  Activity.
CHAP 7. 메뉴와 대화상자. © 2012 생능출판사 All rights reserved 메뉴의 종류 옵션 메뉴 : 사용자가 MENU 키를 누를 때 나타난다. 컨텍스트 메뉴 : 컨텍스트 메뉴는 사용자가 화면을 일정 시간 이상으로 길게 누르면 나타나는 메뉴이다.
아주대학교 LifecareScienceLAB Android Seminar 2 nd class Android Software Development 2011/04/13 – p.m. 06:00 – 팔달관 409 호 아주대학교.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Lab7 – Appendix.
Lab7 – Advanced.
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android N Amanquah.
several communicating screens
GUI Programming Fundamentals
Android Introduction Hello World.
Android Notifications
Communication between Activities
CS499 – Mobile Application Development
Android Widgets 1 7 August 2018
Android Introduction Hello Views Part 1.
ITEC535 – Mobile Programming
Android – Read/Write to External Storage
Android Dialog Boxes AlertDialog - Toast
תכנות ב android אליהו חלסצ'י.
Picasso Revisted.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Note Q) How to format code in Enclipse? A) Ctrl + i
Activities and Intents
Programski jezici za mobilne aplikacije
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Notifications
Adding Components to Activity
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
Lasalle-App Tecnología Móvil.
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

아주대학교 LifecareScienceLAB Android Seminar 3 rd class Android Software Development 2011/05/04 – p.m. 06:00 – 팔달관 409 호 아주대학교

Review  User Interface  Button, TextView, EditText  LinearLayout  Software Design Tool

Widget  TextView, Button, EditText 를 이용 하여 버튼을 누르 면 편집한 문자열 이 출력되는 예제 main.xml →

Widget ↓ Activity Class

State Diagram Not Playing, At the beginning PlayingPaused Play Pause Stop Pause Stop

Structure Chart main process Input ouput sub process 2 sub process 1 sub process 3 print

Flow Chart i <= 0 Turn on All LED Output Data in Array[i] to LED i++ False True Add Random Value to Array Array Size + 1 START i <= 0 i < Array Size? Turn on All LED Input Data from Button False True Array[i] == Input? True i++ Clear Array Array Size <= 0 Clear Array Array Size <= 0 False i <= 0 i < Array Size?

Class Diagram Class Explain Builder 문서를 구성하기 위한 메소드를 결정하는 추상 클래스 Director 한 개의 문서를 만드는 클래스 TextBuilder 일반 텍스트 ( 보통의 문자열 ) 를 이용해서 문서를 만드는 클래스 HTMLBuilder HTML 파일을 이용해서 문서를 만드는 클래스 Main 동작 테스트용 클래스 Builder makeTitle makeString makeItems close TextBuilder buffer makeTitle makeString makeItems close getResult makeTitle makeString makeItems close getResult HTMLBuilder Director builder construct filename writer Uses ▲ Main Uses ▶ Uses ▲

Sequence Diagram :Client:Server:Device work open print close write

Contents List Android Activity Toast Log Software Development Design Presentation

아주대학교 ANDROID Activity Toast Log

Activity  프로그램에서의 “ 화면 하나 ”  반드시 “View” 나 “View Group” 를 가져야 한다.  액티비티는 서로 중첩되지 않으며 독립적이 다.(View 는 중첩된다.)

Activity LifeCycle

Activity 추가 MainActivity.java Activity SubActivity.java Activity mainactivity.xml View subactivity.xml View

 프로젝트 생성 Create Activity : MainActivity →

main.xml 파일 이름 바꾸기

SubActivity Class 추가하기

subactivity xml 파일 추가하기

AndroidManifest 파일에 등록하기

MainActivity.java import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { /** Called when the activity is first created. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainactivity); Button btnCall = (Button)findViewById(R.id.call); btnCall.setOnClickListener(new OnClickListener(){ public void onClick(View v){ Intent intent = new Intent(MainActivity.this, SubActivity.class); startActivity(intent); } }); }

mainactivity.xml <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=" 메인 엑티비티입니다." android:textSize="30dp" android:textColor="#FF0000" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Call" >

SubActivity.java import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class SubActivity extends Activity { /** Called when the activity is first created. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.subactivity); Button btnClose = (Button)findViewById(R.id.close); btnClose.setOnClickListener(new OnClickListener(){ public void onClick(View v){ finish(); } }); }

subactivity.xml <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text=" 메인에서 호출한 서브입니다." android:textSize="20dp" android:textColor="#00FF00" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Close" >

Activity 간의 통신  인텐트는 액티비티간에 인수와 리턴값을 전달하는 도구로도 사용된다.  값을 저장하는 Method  Intent putExtra(String name, int value)  Intent putExtra(String name, String value)  Intent putExtra(String name, boolean value)  저장된 값을 꺼내오는 Method  int getIntExtra(String name, int defaultValue)  String getStringExtra(String name)  boolean getBooleanExtra(String name, boolean defaultValue)  리턴값을 돌려받기 위해 누가 호출했는지 알려주는 Method  public void startActivityForResult(Intent intent, int requestCode)  리턴값을 돌려받는 Method  Protected void onActivityResult(int requestCode, int resultCode, Intent data)

Activity 간의 통신 CommActivity.java Activity ActEdit.java Activity main.xml View sub.xml View

CommActivity.java  import android.app.*;  import android.content.*;  import android.os.*;  import android.view.*;  import android.widget.*;  public class CommActivity extends Activity {  TextView mText;  final static int ACT_EDIT = 0;  public void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.main);  mText = (TextView)findViewById(R.id.textView);  Button btnEdit=(Button)findViewById(R.id.buttonNEXT);  btnEdit.setOnClickListener(new Button.OnClickListener() {  public void onClick(View v) {  Intent intent = new Intent(CommActivity.this, ActEdit.class);  intent.putExtra("TextIn", mText.getText().toString());  startActivityForResult(intent,ACT_EDIT);  }  });  }   protected void onActivityResult (int requestCode, int resultCode, Intent data) {  switch (requestCode) {  case ACT_EDIT:  if (resultCode == RESULT_OK) {  mText.setText(data.getStringExtra("TextOut"));  }  break;  }

main.xml   <LinearLayout xmlns:android="  android:orientation="vertical"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  >  <TextView  android:text="TextView"  android:layout_height="wrap_content"   android:textSize="30dp"  android:layout_width="fill_parent"  >  <Button  android:layout_height="wrap_content"   android:text="EDIT"  android:layout_width="fill_parent"  android:textSize="20dp"  > 

ActEdit.java  import android.app.*;  import android.content.*;  import android.os.*;  import android.view.*;  import android.widget.*;  public class ActEdit extends Activity {  EditText mEdit;  public void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.sub);  mEdit = (EditText)findViewById(R.id.editText);  Intent intent = getIntent();  mEdit.setText(intent.getStringExtra("TextIn"));  Button btnOK=(Button)findViewById(R.id.buttonOK);  btnOK.setOnClickListener(new Button.OnClickListener() {  public void onClick(View v) {  Intent intent = new Intent();  intent.putExtra("TextOut", mEdit.getText().toString());  setResult(RESULT_OK,intent);  finish();  }  });  Button btnCancel=(Button)findViewById(R.id.buttonCANCEL);  btnCancel.setOnClickListener(new Button.OnClickListener() {  public void onClick(View v) {  setResult(RESULT_CANCELED);  finish();  }  });  }

sub.xml   <LinearLayout  xmlns:android="  android:layout_width="fill_parent"  android:layout_height="fill_parent" android:orientation="vertical">  <EditText  android:text="EditText"  android:layout_height="wrap_content"   android:layout_width="fill_parent"  android:textSize="30dp"  >  <Button  android:layout_height="wrap_content"   android:text="OK"  android:layout_width="fill_parent"  android:textSize="20dp"  >  <Button  android:layout_height="wrap_content"   android:text="CANCEL"  android:layout_width="fill_parent"  android:textSize="20dp"  > 

Activity 간의 통신 CommActivity.java Activity ActEdit.java Activity new intent +Caller, +Callee getIntent putExtra +TextIn startActivityForResult getStringExtra TextIn new intent putExtra +TextOut setResut onActivityResult getStringExtra TextOut TextIn TextOut

Toast  작은 팝업 대화상자  초보자들에게 디버깅용, 학습용으로 아주 용이한 출력 방법  변수 값을 수시로 찍어볼 때 등

Toast  생성 Method  static Toast makeToast(Context context, int resId, int duration)  context : 메시지를 출력하는 주체  MainActivity.this  resId : 출력할 문자열의 ID  R.String.name  duration : 메시지 출력 지속시간  LENGTH_SHORT, LENGTH_LONG  static Toast makeToast(Context context, CharSequence text, int duration)  text : 출력할 메시지  “LifecareScienceLAB”  옵션 Method  void setGravity(int gravity, int, xOffset, int yOffset)  void setMargin(float horizonMargin, float verticalMargin)  void setText(CharSequence s)  void setDuration(int duration)  void setView(View view)  메시지를 보이거나 숨기는 Method  void show()  void cancel()

ToastTest.java  import android.app.*;  import android.os.*;  import android.view.*;  import android.widget.*;  import exam.AndroidExam.*;  public class ToastTest extends Activity {  Toast mToast = null;  int count;  String str;  public void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.main);   findViewById(R.id.shortmsg).setOnClickListener(mClickListener);  findViewById(R.id.longmsg).setOnClickListener(mClickListener);  findViewById(R.id.count1).setOnClickListener(mClickListener);  findViewById(R.id.count2).setOnClickListener(mClickListener);  findViewById(R.id.customview).setOnClickListener(mClickListener);  }  Button.OnClickListener mClickListener = new Button.OnClickListener() {  public void onClick(View v) {  switch (v.getId()) {  case R.id.shortmsg:  Toast.makeText(ToastTest.this, " 잠시 나타나는 메시지 ",  Toast.LENGTH_SHORT).show();  break;  case R.id.longmsg:  Toast.makeText(ToastTest.this, " 조금 길게 나타나는 메시지 ",  Toast.LENGTH_LONG).show();  break;  case R.id.count1:  str = " 현재 카운트 = " + count++;  if (mToast != null) {  mToast.cancel();  }  mToast = Toast.makeText(ToastTest.this, str, Toast.LENGTH_SHORT);  mToast.show();  break;  case R.id.count2:  str = " 현재 카운트 = " + count++;  if (mToast == null) {  mToast = Toast.makeText(ToastTest.this, str, Toast.LENGTH_SHORT);  } else {  mToast.setText(str);  }  mToast.show();  break;  case R.id.customview:  LinearLayout linear = (LinearLayout)View.inflate(ToastTest.this,  R.layout.output_toast, null);  Toast t2 = new Toast(ToastTest.this);  t2.setView(linear);  t2.show();  break;  }  };  }

main.xml   <LinearLayout xmlns:android="  android:orientation="vertical"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  >  <Button   android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text=" 짧은 메시지 "  />  <Button   android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text=" 긴 메시지 "  />  <Button   android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text=" 카운트 연속 출력 "  />  <Button   android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text=" 카운트 연속 출력 2"  />  <Button   android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text=" 커스텀 뷰 표시 "  /> 

Log  개발자를 위한 디버깅용 메시지  Eclipse 를 통해서만 확인 가능  LogCat 을 이용하여 확인 할 수 있다.  다양한 메시지 필터  Log.v : verbose  Log.i : information  Log.w : warning  Log.e : error  Log.d : debugging  Log.x(String tag, String msg)  tag : 사용자 정의 메시지 분류  msg : 출력할 메시지

아주대학교 SOFTWARE DEVELOPMENT Design Presentation