SlideShare une entreprise Scribd logo
1  sur  16
ANDROID 세미나
FOR BEGINNER (2)
     PoolC 홍철주
     2012. 4. 18
RESOURCE -> SOURCE CODE
  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" >

      <TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/hello" />

      <Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Button" />

  </LinearLayout>
RESOURCE -> SOURCE CODE
RESOURCE -> SOURCE CODE

  public class TestActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          Button mButton = (Button)findViewById(R.id.button1);
      }
  }
RESOURCE -> SOURCE CODE
  public final class R {
      public static final class attr {
      }
      public static final class drawable {
          public static final int ic_launcher=0x7f020000;
      }
      public static final class id {
          public static final int button1=0x7f050000;
      }
      public static final class layout {
          public static final int main=0x7f030000;
      }
      public static final class string {
          public static final int app_name=0x7f040001;
          public static final int hello=0x7f040000;
      }
  }
RESOURCE -> SOURCE CODE


 {ResourceType} {Varible} = (ResourceType)findViewById(ResourceAddress);
RESOURCE -> SOURCE CODE
        Button mButton = (Button)findViewById(R.id.button1);

        // Button Listener : onClick -> call a function
        mButton.setOnClickListener(new Button.OnClickListener(){

 	 	 	 public void onClick(View v) {
 	 	 	 	 // TODO Auto-generated method stub
 	 	 	 	 Toast.makeText(getApplicationContext(), "Hello, World",
 Toast.LENGTH_SHORT).show();
 	 	 	 }
         });
ACTIVITY


• 일단은   보이는 화면이라고 생각

• 당신은   화면 위에다가 터치도 하고 이것 저것한다

 • 입력도   받고 출력도 받고

• 액티비티   주기를 볼 필요가 있긴 한데...
INTENT


• 안드로이드에서의       의사표현 수단

• 어떤   component를 부른다!

• 그리고   무엇을 해달라고 요청!
CONTEXT


• 어플리케이션    환경의 전역 정보에 접근하기 위한 인터
페이스

• 시스템   정보 접근, API 호출

• 액티비티간    리소스 공유 등..
INTENT -> NEW ACTIVITY!


	   Intent mIntent = new Intent(TestActivity.this, SecondActivity.class);
	   	 	 	 startActivity(mIntent);
	   	 	

                 Intent 의 생성자는 여러가지.
                        이는 그 중 하나.
SIMPLE CALCULATOR


                op1
opr
                op2


                result
SIMPLE CALCULATOR


   	   EditText op1, op2;
   	   TextView opr, result;
   	   Button plus, minus, mul, div;
SIMPLE CALCULATOR
               public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.main);

                      op1 = (EditText)findViewById(R.id.op1);
                      op2 = (EditText)findViewById(R.id.op2);
                      opr = (TextView)findViewById(R.id.opr);
                      result = (TextView)findViewById(R.id.result);

                      plus = (Button)findViewById(R.id.plus);
                      plus.setOnClickListener(this);
                      minus = (Button)findViewById(R.id.minus);
                      minus.setOnClickListener(this);
                      mul = (Button)findViewById(R.id.mul);
                      mul.setOnClickListener(this);
                      div = (Button)findViewById(R.id.div);
                      div.setOnClickListener(this);

                  }
                                      this? -> activity
public class TestActivity extends Activity implements View.OnClickListener
SIMPLE CALCULATOR
  public   void onClick(View v) {
  	 	      // TODO Auto-generated method stub
  	 	      switch(v.getId()) {
  	 	      case R.id.plus:
  	 	      	 process(Operator.plus);
  	 	      	 break;
  	 	      case R.id.minus:
  	 	      	 process(Operator.minus);
  	 	      	 break;
  	 	      case R.id.mul:
  	 	      	 process(Operator.mul);
  	 	      	 break;
  	 	      case R.id.div:
  	 	      	 process(Operator.div);
  	 	      	 break;
  	 	      }
  	 }
SIMPLE CALCULATOR
void process(Operator op)
	   {
	   	  int op1Num = Integer.parseInt(op1.getText().toString());
	   	  int op2Num = Integer.parseInt(op2.getText().toString());
	   	  double resultNum = 0;
	   	
	   	  switch(op)
	   	  {
	   	  case plus:
	   	  	   resultNum = op1Num + op2Num;
	   	  	   opr.setText("+");
	   	  	   break;
	   	  case minus:
	   	  	   resultNum = op1Num - op2Num;
	   	  	   opr.setText("-");
	   	  	   break;
	   	  case mul:
	   	  	   resultNum = op1Num * op2Num;
	   	  	   opr.setText("*");
	   	  	   break;
	   	  case div:
	   	  	   resultNum = (double)op1Num / op2Num;
	   	  	   opr.setText("/");
	   	  	   break;
	   	  }
	   	
	   	  result.setText(Double.toString(resultNum));

Contenu connexe

Tendances

VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
Darwin Durand
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
Taha Shakeel
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
Inbal Geffen
 
Authentication Functions
Authentication FunctionsAuthentication Functions
Authentication Functions
Valerie Rickert
 

Tendances (16)

VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Understanding Functions and "this" in the World of ES2017+
Understanding Functions and "this" in the World of ES2017+Understanding Functions and "this" in the World of ES2017+
Understanding Functions and "this" in the World of ES2017+
 
Business Rules with Brick
Business Rules with BrickBusiness Rules with Brick
Business Rules with Brick
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
5. CodeIgniter copy1
5. CodeIgniter copy15. CodeIgniter copy1
5. CodeIgniter copy1
 
Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux ApplicaitonsStrategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitons
 
Zend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency InjectionZend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency Injection
 
Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
My Development Story
My Development StoryMy Development Story
My Development Story
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Intro to Advanced JavaScript
Intro to Advanced JavaScriptIntro to Advanced JavaScript
Intro to Advanced JavaScript
 
What is the difference between a good and a bad repository? (Forum PHP 2018)
What is the difference between a good and a bad repository? (Forum PHP 2018)What is the difference between a good and a bad repository? (Forum PHP 2018)
What is the difference between a good and a bad repository? (Forum PHP 2018)
 
Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012
 
culadora cientifica en java
culadora cientifica en javaculadora cientifica en java
culadora cientifica en java
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Authentication Functions
Authentication FunctionsAuthentication Functions
Authentication Functions
 

En vedette

リーンスタートアップ2012‐2
リーンスタートアップ2012‐2リーンスタートアップ2012‐2
リーンスタートアップ2012‐2
Masaki Yoshida
 
Using Facebook For Your Business
Using Facebook For Your BusinessUsing Facebook For Your Business
Using Facebook For Your Business
OCG PR
 
Toplanti yonetimi-ozel-dersi
Toplanti yonetimi-ozel-dersiToplanti yonetimi-ozel-dersi
Toplanti yonetimi-ozel-dersi
zeynep_zyn85
 
Truzim meslek-lisesi
Truzim meslek-lisesiTruzim meslek-lisesi
Truzim meslek-lisesi
zeynep_zyn85
 

En vedette (11)

Figurative language
Figurative languageFigurative language
Figurative language
 
Tours in Mexico
Tours in MexicoTours in Mexico
Tours in Mexico
 
リーンスタートアップ2012‐2
リーンスタートアップ2012‐2リーンスタートアップ2012‐2
リーンスタートアップ2012‐2
 
Using Facebook For Your Business
Using Facebook For Your BusinessUsing Facebook For Your Business
Using Facebook For Your Business
 
Presentation1
Presentation1Presentation1
Presentation1
 
Contaminación
ContaminaciónContaminación
Contaminación
 
Are Your Ready for Your Next Formulary Win?
Are Your Ready for Your Next Formulary Win?Are Your Ready for Your Next Formulary Win?
Are Your Ready for Your Next Formulary Win?
 
Toplanti yonetimi-ozel-dersi
Toplanti yonetimi-ozel-dersiToplanti yonetimi-ozel-dersi
Toplanti yonetimi-ozel-dersi
 
Truzim meslek-lisesi
Truzim meslek-lisesiTruzim meslek-lisesi
Truzim meslek-lisesi
 
Trakya edu
Trakya eduTrakya edu
Trakya edu
 
دراسة الخصائص التصميمية للفراغات العمرانية الخاصة بالاحياء السكنية
دراسة الخصائص التصميمية للفراغات العمرانية الخاصة بالاحياء السكنيةدراسة الخصائص التصميمية للفراغات العمرانية الخاصة بالاحياء السكنية
دراسة الخصائص التصميمية للفراغات العمرانية الخاصة بالاحياء السكنية
 

Similaire à 안드로이드 세미나 2

Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
Jussi Pohjolainen
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
Utkarsh Mankad
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 

Similaire à 안드로이드 세미나 2 (20)

Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intent
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
Day 5
Day 5Day 5
Day 5
 
Android Location-based應用開發分享
Android Location-based應用開發分享Android Location-based應用開發分享
Android Location-based應用開發分享
 
20 Codigos
20 Codigos20 Codigos
20 Codigos
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Android 3
Android 3Android 3
Android 3
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your apps
 
Practical
PracticalPractical
Practical
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Minicurso Android
Minicurso AndroidMinicurso Android
Minicurso Android
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Action bar
Action barAction bar
Action bar
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Android development - Activities, Views & Intents
Android development - Activities, Views & IntentsAndroid development - Activities, Views & Intents
Android development - Activities, Views & Intents
 
Saindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidSaindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender android
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
HNUH
HNUHHNUH
HNUH
 
20 codigos
20 codigos20 codigos
20 codigos
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

안드로이드 세미나 2

  • 1. ANDROID 세미나 FOR BEGINNER (2) PoolC 홍철주 2012. 4. 18
  • 2. RESOURCE -> SOURCE CODE <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout>
  • 4. RESOURCE -> SOURCE CODE public class TestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button mButton = (Button)findViewById(R.id.button1); } }
  • 5. RESOURCE -> SOURCE CODE public final class R { public static final class attr { } public static final class drawable { public static final int ic_launcher=0x7f020000; } public static final class id { public static final int button1=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; } }
  • 6. RESOURCE -> SOURCE CODE {ResourceType} {Varible} = (ResourceType)findViewById(ResourceAddress);
  • 7. RESOURCE -> SOURCE CODE Button mButton = (Button)findViewById(R.id.button1); // Button Listener : onClick -> call a function mButton.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "Hello, World", Toast.LENGTH_SHORT).show(); } });
  • 8. ACTIVITY • 일단은 보이는 화면이라고 생각 • 당신은 화면 위에다가 터치도 하고 이것 저것한다 • 입력도 받고 출력도 받고 • 액티비티 주기를 볼 필요가 있긴 한데...
  • 9. INTENT • 안드로이드에서의 의사표현 수단 • 어떤 component를 부른다! • 그리고 무엇을 해달라고 요청!
  • 10. CONTEXT • 어플리케이션 환경의 전역 정보에 접근하기 위한 인터 페이스 • 시스템 정보 접근, API 호출 • 액티비티간 리소스 공유 등..
  • 11. INTENT -> NEW ACTIVITY! Intent mIntent = new Intent(TestActivity.this, SecondActivity.class); startActivity(mIntent); Intent 의 생성자는 여러가지. 이는 그 중 하나.
  • 12. SIMPLE CALCULATOR op1 opr op2 result
  • 13. SIMPLE CALCULATOR EditText op1, op2; TextView opr, result; Button plus, minus, mul, div;
  • 14. SIMPLE CALCULATOR public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); op1 = (EditText)findViewById(R.id.op1); op2 = (EditText)findViewById(R.id.op2); opr = (TextView)findViewById(R.id.opr); result = (TextView)findViewById(R.id.result); plus = (Button)findViewById(R.id.plus); plus.setOnClickListener(this); minus = (Button)findViewById(R.id.minus); minus.setOnClickListener(this); mul = (Button)findViewById(R.id.mul); mul.setOnClickListener(this); div = (Button)findViewById(R.id.div); div.setOnClickListener(this); } this? -> activity public class TestActivity extends Activity implements View.OnClickListener
  • 15. SIMPLE CALCULATOR public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()) { case R.id.plus: process(Operator.plus); break; case R.id.minus: process(Operator.minus); break; case R.id.mul: process(Operator.mul); break; case R.id.div: process(Operator.div); break; } }
  • 16. SIMPLE CALCULATOR void process(Operator op) { int op1Num = Integer.parseInt(op1.getText().toString()); int op2Num = Integer.parseInt(op2.getText().toString()); double resultNum = 0; switch(op) { case plus: resultNum = op1Num + op2Num; opr.setText("+"); break; case minus: resultNum = op1Num - op2Num; opr.setText("-"); break; case mul: resultNum = op1Num * op2Num; opr.setText("*"); break; case div: resultNum = (double)op1Num / op2Num; opr.setText("/"); break; } result.setText(Double.toString(resultNum));

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n